On Fri, 24 Dec 1999 10:37:35 GMT, Ben Smithurst wrote:
> > Could somebody try this piece of code on a -STABLE machine, just out of
> > curiosity...?
>
> I did, it gets SIGFPE too.
I think this boils down to my lack of understanding of IEEE floating
point arithmetic standards.
The following code behaves the same on every box I can find to test it
on. Although I'm surprised that the exception is INV instead of OFL, it
seems to be standard behaviour.
Ciao,
Sheldon.
#include <ieeefp.h>
#include <stdio.h>
void
do_weird(void)
{
double x;
int i;
printf("double x = 1e19; int i = (int)x\n");
x = 1e19;
i = (int)x;
printf("%d\n", i);
}
int
main(void)
{
printf("clearing fp exception mask\n");
(void)fpsetmask(0);
do_weird();
printf("setting fp exception mask to FP_X_OFL\n");
(void)fpsetmask(FP_X_OFL);
do_weird();
printf("setting fp exception mask to FP_X_INV\n");
(void)fpsetmask(FP_X_INV);
do_weird();
return 0;
}
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message