This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mattip
Recipients loewis, mattip
Date 2012-04-07.22:26:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333837594.56.0.0638199732618.issue14521@psf.upfronthosting.co.za>
In-reply-to
Content
It appears that microsoft decided NAN will be represented by '\x00\x00\x00\x00\x00\x00\xf8\xff', which has the sign bit set. 
Compiling this c code with visual 9.0 gives the correct answers for the first value, and a mess for the second:

#include <math.h>
#include <stdio.h>
#include <float.h>

int main( void ) {
   unsigned long nan[2]={0xffffffff, 0x7fffffff};
   double g;
   double z, zn;
   int i;
   for (i=0;i<2; i++)
   {    
       g = *( double* )(nan+i);
       printf( "g( %g ) is NaN, _isnan(g) %d\n", g, _isnan(g) );
       z = _copysign(-3, g);
       zn = _copysign(-3, -g);
       printf("z=%g, zn=%g\n", z, zn);
   }
   return 0;
}

This corresponds with loewis 's observation.
History
Date User Action Args
2012-04-07 22:26:34mattipsetrecipients: + mattip, loewis
2012-04-07 22:26:34mattipsetmessageid: <1333837594.56.0.0638199732618.issue14521@psf.upfronthosting.co.za>
2012-04-07 22:26:33mattiplinkissue14521 messages
2012-04-07 22:26:33mattipcreate