[Numpy-discussion] uint64 typecasting with scalars broken (?)

Charles R Harris charlesr.harris at gmail.com
Sun Apr 22 20:54:01 EDT 2007


On 4/22/07, Charles R Harris <charlesr.harris at gmail.com> wrote:
>
>
>
> On 4/22/07, Christian Marquardt <christian at marquardt.sc> 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'>
> >
> > 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'>
>
>
> Looks like a bug to me:
>
> In [5]: x = array([1],dtype=uint64)
>
> In [6]: type(x[0])
> Out[6]: <type 'numpy.uint64'>
>
> In [7]: type(x[0]+1)
> Out[7]: <type 'numpy.float64'>
>

Python integers should have enough precision to hold the result, although a
long integer would have to be used. I suspect this is an artifact of
considering regular python integers, which don't have the needed precision,
hence the double (which is a bit small itself).

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070422/8bdfc462/attachment.html>


More information about the NumPy-Discussion mailing list