[Numpy-discussion] Question about 64-bit integers being cast to double precision
oliphant at ee.byu.edu
Sun Oct 9 21:28:33 EDT 2005
What is the opinion of people here regarding the casting of 64-bit
integers to double precision.
In scipy (as in Numeric), there is the concept of "Casting safely" to a
type. This concept is used when choosing a ufunc, for example.
My understanding is that a 64-bit integer cannot be cast safely to a
double-precision floating point number, because precision is lost in the
conversion. However, at least a signed 64-bit integer can usually be
cast safely to a long double precision floating point number.
This is not too big a deal on 32-bit systems where people rarely request
However, on some 64-bit systems (where the C long is 64-bit), Python's
default integer is 64-bit. Therefore, simple expressions like sqrt(2)
which require conversion to floating point will look for the first
floating point number that it can convert a 64-bit integer to safely.
This can only be a long double.
The result is that on 64-bit systems, the long double type gets used a
lot more. Is this acceptable? expected? What do those of you on
64-bit systems think?
More information about the NumPy-Discussion