[Numpy-discussion] np.longlong casts to int

Francesc Alted francesc@continuum...
Thu Feb 23 05:40:10 CST 2012


On Feb 23, 2012, at 3:06 AM, Pierre Haessig wrote:

> Hi,
> Le 23/02/2012 02:24, Matthew Brett a écrit :
>> Luckily I was in fact using longdouble in the live code,
> I had never "exotic" floating point precision, so thanks for your post
> which made me take a look at docstring and documentation.
> 
> If I got it right from the docstring, 'np.longdouble', 'np.longfloat'
> are all in fact 'np.float128'.
> (numpy 1.5)

That in fact depends on the platform you are using.  Typically, for 32-bit platforms, 'np.longfloat' and 'np.longdouble' are bound to 'np.float96', while in 64-bit are to 'np.float128'.

> However, I was surprised that float128 is not mentioned in the array of
> available types in the user guide.
> http://docs.scipy.org/doc/numpy/user/basics.types.html
> Is there a specific reason for this absence, or is just about visiting
> the documentation wiki ;-) ?

The reason is most probably that you cannot get a float96 or float128 whenever you want (depends on your architecture), so adding these types to the manual could be misleading.  However, I'd advocate to document them while warning about platform portability issues.

> Additionally, I don't know what are the writing guidelines of the user
> guide, but would it make sense to add some "new numpy 1.x" messages as
> in the Python doc. I'm thinking here of np.float16. I know it exists
> from messages on this mailing list but my 1.5 don't have it.

float16 was introduced in NumPy 1.6, IIRC.

> PS : I found float128 mentionned in the reference
> http://docs.scipy.org/doc/numpy/reference/arrays.scalars.html#built-in-scalar-types
> However, it is not as easily readable as the user guide (which makes
> sense !).
> 
> Does the following statements mean that those types are not available on
> all platforms ?
> float96     96 bits, platform?      
> float128     128 bits, platform?

Exactly.  I'd update this to read:

float96    96 bits.  Only available on 32-bit (i386) platforms.
float128  128 bits.  Only available on 64-bit (AMD64) platforms.

-- Francesc Alted





More information about the NumPy-Discussion mailing list