|
From: Tatsuro M. <tma...@ya...> - 2010-10-05 04:13:55
|
Hello
For current windows binaries,
gnuplot> pr NaN
0.0
This is not correct.
For the cygwin and the djgpp (modified recently) give
gnuplot> pr NaN
NaN
I have googled NaN for the MinGW, I have not obtained good information yet.
So I have written the test code the below
**************************************
#include <stdio.h>
#include <math.h>
int main(void){
double dbl;
unsigned long uldbl[2];
printf("test 0.0/0.0\n");
dbl = 0.0/0.0;
*( double* )uldbl = dbl;
printf("%f \n",dbl);
printf("isnan = %d \n",isnan(dbl));
printf("%x %x\n", uldbl[0], uldbl[1]);
printf("\n");
printf("test 0xffffffff 0x7fffffff \n");
uldbl[0]=0xffffffff; uldbl[1]= 0x7fffffff;
dbl = *( double* )uldbl;
printf("%f \n",dbl);
printf("isnan = %d \n",isnan(dbl));
printf("%x %x\n", uldbl[0], uldbl[1]);
printf("\n");
printf("test atof(\"NaN\") \n");
dbl = atof("NaN");
*( double* )uldbl = dbl;
printf("%f \n",dbl);
printf("isnan = %d \n",isnan(dbl));
printf("%x %x\n", uldbl[0], uldbl[1]);
printf("\n");
printf("test atof(\"-1.#IND00\") \n");
dbl = atof("-1.#IND00");
*( double* )uldbl = dbl;
printf("%f \n",dbl);
printf("isnan = %d \n",isnan(dbl));
printf("%x %x\n", uldbl[0], uldbl[1]);
printf("\n");
printf("test atof(\"1.#QNAN0\") \n");
dbl = atof("1.#QNAN0");
*( double* )uldbl = dbl;
printf("%f \n",dbl);
printf("isnan = %d \n",isnan(dbl));
printf("%x %x\n", uldbl[0], uldbl[1]);
printf("\n");
printf("test 0 \n");
dbl = 0;
*( double* )uldbl = dbl;
printf("%f \n",dbl);
printf("isnan = %d \n",isnan(dbl));
printf("%x %x\n", uldbl[0], uldbl[1]);
printf("\n");
return 0;
}
*************************
The results are
$ ./nan
test 0.0/0.0
-1.#IND00
isnan = 1
0 fff80000
test 0xffffffff 0x7fffffff
1.#QNAN0
isnan = 1
ffffffff 7fffffff
test atof("NaN")
2293504.000000
isnan = 0
0 41417f80
test atof("-1.#IND00")
2293504.000000
isnan = 0
0 41417f80
test atof("1.#QNAN0")
2293504.000000
isnan = 0
0 41417f80
test 0
0.000000
isnan = 0
0 0
#******************
>From above it seems to be
unsigned long lnan[2]={0xffffffff, 0x7fffffff};
return *( double* )lnan;
is applicable as for the MSC and djgpp.
So I changed from
#if defined (__MSC__) || defined (DJGPP) || defined(__DJGPP__)
to
#if defined (__MSC__) || defined (DJGPP) || defined(__DJGPP__) || defined (__MinGW32__)
but pr NaN gives 0.0.
This is the current situation.
Any suggestions?
Regards
Tatsuro
--------------------------------------
Learn more about breast cancer - Pink Ribbon Campaign 2010
http://yj.pn/JAy9L7
|