Message157761
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. |
|
Date |
User |
Action |
Args |
2012-04-07 22:26:34 | mattip | set | recipients:
+ mattip, loewis |
2012-04-07 22:26:34 | mattip | set | messageid: <1333837594.56.0.0638199732618.issue14521@psf.upfronthosting.co.za> |
2012-04-07 22:26:33 | mattip | link | issue14521 messages |
2012-04-07 22:26:33 | mattip | create | |
|