[Numpy-discussion] Unwanted upcast from uint64 to float64
Travis Oliphant
oliphant.travis at ieee.org
Thu Aug 31 08:45:46 CDT 2006
Torgil Svensson wrote:
> I'm using windows datetimes (100nano-seconds since 0001,1,1) as time
> in a numpy array and was hit by this behaviour.
>
>
>>>> numpy.__version__
>>>>
> '1.0b4'
>
>>>> a=numpy.array([632925394330000000L],numpy.uint64)
>>>> t=a[0]
>>>> t
>>>>
> 632925394330000000L
>
>>>> type(t)
>>>>
> <type 'numpy.uint64'>
>
>>>> t+1
>>>>
> 6.3292539433e+017
>
>>>> type(t+1)
>>>>
> <type 'numpy.float64'>
>
>>>> t==(t+1)
>>>>
> True
>
> I was trying to set t larger than any time in an array. Is there any
> reason for the scalar to upcast in this case?
>
Yes, because you are adding a signed scalar to an unsigned scalar and a
float64 is the only thing that can handle it (well actually it should be
the long double scalar but we've made a special case here because long
doubles are not that common). Add an unsigned scalar
t+numpy.uint64(1)
to get what you want.
-Travis
> //Torgil
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
More information about the Numpy-discussion
mailing list