[SciPy-user] float96 displayed (incorrectly) as float64

David Cournapeau david at ar.media.kyoto-u.ac.jp
Thu Feb 19 00:33:37 EST 2009


Michael Abshoff wrote:
> David Cournapeau wrote:
>   
>> On Thu, Feb 19, 2009 at 3:42 AM, Leo Trottier <trottier+pylist at gmail.com> wrote:
>>     
>>> Hi,
>>>       
>
> Hi,
>
>   
>>> I'd like to show off how much easier it is to work with multiple data types
>>> in numpy (as compared with matlab).  It would be especially handy to show
>>> off float96 , etc.
>>>
>>> Unfortunately, this doesn't seem to work under Vista or Windows XP
>>>       
>> Windows does not support long double - long double is exactly the same
>> as double on this platform.
>>     
>
> The C99 standard does not guarantee that long double is any "longer" 
> than double. Nearly all systems, but Windows do have a long double that 
> is either 96 or 128 bits. But it is wrong to assume that this is always 
> the case and it is not a violation of the C99 standard.
>   

I kept things simple, but you're right that the real problem is more
complicated. For once, long double being bigger than double is not a OS
problem, but a compiler + CPU problem. On windows, it is made
complicated by the fact that that sizeof(long double) > sizeof(double)
for gcc, even on windows, but that windows C runtime does not support
this You can check that the problem is printing, not computation
(example untested):

import numpy as np
a  = np.float96(1.)
print a # bogus, 0.
b = 2 * a
print np.double(b) # print 2.

Pauli and me have spent some time to fix various formatting issues, and
I also added some support to make sure long double is converted to
double before any printing on windows,

cheers,

David



More information about the SciPy-User mailing list