[issue14521] math.copysign(1., float('nan')) returns -1.
mattip
report at bugs.python.org
Sun Apr 8 00:26:34 CEST 2012
mattip <matti.picus at gmail.com> added the comment:
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.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14521>
_______________________________________
More information about the Python-bugs-list
mailing list