F
Francois Grieu
Does ISO C insure this program's output is 0 ?
#include <fenv.h>
#include <math.h>
int main(void)
{
#ifdef FE_TOWARDZERO
unsigned long a;
double d;
int j;
fesetround(FE_TOWARDZERO);
a = 0xFFFFFFFF;
d = 0;
for(j=10;--j
d = (d+a)*((double)1/65536/65536);
do
if ((unsigned long)floor(d*a)==a)
return 1;
while (--a);
#endif
return 0;
}
As an aside, my <fenv.h> defines FE_TOWARDZERO as an enum,
isn't that a defect (assuming FE_TOWARDZERO is supported)?
François Grieu
#include <fenv.h>
#include <math.h>
int main(void)
{
#ifdef FE_TOWARDZERO
unsigned long a;
double d;
int j;
fesetround(FE_TOWARDZERO);
a = 0xFFFFFFFF;
d = 0;
for(j=10;--j
d = (d+a)*((double)1/65536/65536);
do
if ((unsigned long)floor(d*a)==a)
return 1;
while (--a);
#endif
return 0;
}
As an aside, my <fenv.h> defines FE_TOWARDZERO as an enum,
isn't that a defect (assuming FE_TOWARDZERO is supported)?
François Grieu