[Numpy-discussion] Incorrect OverflowError?
Todd Miller
jmiller at stsci.edu
Thu Oct 23 13:31:25 EDT 2003
On Thu, 2003-10-23 at 11:36, Edward C. Jones wrote:
> #! /usr/bin/env python
>
> import numarray
> from numarray.numerictypes import *
>
> # I run Gentoo 1.4 Linux with gcc 3.2.2.
>
> numarray.Error.setMode(all='ignore')
>
> arr = numarray.zeros((1,), Float64)
> arr[0] = 4000000000.0
> print '%f' % arr[0]
> try:
> arr[0] = 4000000000
> print "Doesn't get here."
> except OverflowError, s:
> print 'Python OverflowError raised'
> print s
> # OverflowError: long int too large to convert to int
>
> # The Python long "4000000000" can be represented as a C double.
> # If the OverflowError came from numarray, why was an exception raised?
> # Are these problems bugs?
>
Yes. The bug was a use of PyLong_AsLong instead of PyLong_AsLongLong.
Keep looking! :-)
Thanks,
Todd
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: The SF.net Donation Program.
> Do you like what SourceForge.net is doing for the Open
> Source Community? Make a contribution, and help us add new
> features and functionality. Click here: http://sourceforge.net/donate/
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
--
Todd Miller
Space Telescope Science Institute
3700 San Martin Drive
Baltimore MD, 21030
(410) 338 - 4576
More information about the NumPy-Discussion
mailing list