[Numpy-discussion] Integer cast problems

Gregor Thalhammer gregor.thalhammer@gmail....
Thu Feb 12 11:36:04 CST 2009


Ralph Kube schrieb:
> Hi there,
> I have a little problem here with array indexing, hope you see the problem.
> I use the following loop to calculate some integrals
>
> ...
> 0.145 * 0.005 = 28.999999999999996
> N.int32(0.145 * 0.005) = 28
conversion to int truncates, it doesn't round. Try
N.int32(0.145 * 0.005  +  0.5)

Gregor


More information about the Numpy-discussion mailing list