[Numpy-discussion] uint64 typecasting with scalars broken (?)
Travis Oliphant
oliphant.travis@ieee....
Mon Apr 23 20:44:20 CDT 2007
Christian Marquardt wrote:
> Hello,
>
> The following is what I expected...
>
> >>> y = 1234
> >>> x = array([1], dtype = "uint64")
> >>> print x + y, (x + y).dtype.type
> [1235] <type 'numpy.uint64'>
>
>
This is "what you expect" only because y is a scalar and cannot
determine the "kind" of the output.
> but is this the way it should be? (numpy 1.0.2, Linux, Intel comilers)
>
> >>> print x[0] + y, type(x[0] + y)
> 1235.0 <type 'numpy.float64'>
>
This is correct (sort of) because in a mixed operation between uint64
and int32, because there is no int128, the sum must be placed in a
float. In reality it should be a long-double float but it was decided
not to perpetuate long double floats like this because then on 64-bit
platforms they would be showing up everywhere.
-Travis
More information about the Numpy-discussion
mailing list