MichaelW,
Thanks for the information but _fpreset() does not work or I misunderstand it.
My os is Win764.
After re-reading the page from the link in msg #20 I revised my code a bit.
I'm really not sure if these are related or not?
James
using MinGw 4.8.0
output with: gcc fputest.c -ofputest.exe
unexpected result
d = 12.67
rv = 1266
output with: gcc fputest.c -ofputest.exe -DFPRESET
unexpected result
d = 12.67
rv = 1266
output with: gcc fputest.c -ofputest.exe -DDOUBLE
comparison succeeds
d = 12.67
rv = 1267
using TDM-GCC
output with: gcc fputest.c -ofputest.exe
comparison succeeds
d = 12.67
rv = 1267
New test code:
#include <stdio.h>
#include <float.h>
#ifdef DOUBLE
void
set_fpu (unsigned int mode)
{
asm ("fldcw %0" : : "m" (*&mode));
}
#endif
int foo (double d)
{
printf("%s% .15G\n","d = ",(double)d);
return (d*100);
}
int main (int argc,char** argv)
{
int rv={0};
double d={0};
double c={0};
double a=3.0;
double b=7.0;
#ifdef DOUBLE
set_fpu (0x27F);
#endif
#ifdef FPRESET
_fpreset();
#endif
c= a/ b;
if(c==(a/b))
{
printf("%s\n","comparison succeeds");
}
else
{
printf("%s\n","unexpected result");
}
d= 12.67;
rv= foo( d);
printf("%s% d\n","rv = ",(int)rv);
return 0;
}