Date: Fri, 24 Dec 1999 12:51:23 +0200 From: Sheldon Hearn <sheldonh@uunet.co.za> To: Ben Smithurst <ben@scientia.demon.co.uk> Cc: Bosko Milekic <bmilekic@dsuper.net>, hackers@FreeBSD.ORG Subject: Re: SIGFPE on arithmetic overflow Message-ID: <76436.946032683@axl.noc.iafrica.com> In-Reply-To: Your message of "Fri, 24 Dec 1999 10:37:35 GMT." <19991224103735.A649@strontium.scientia.demon.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?76436.946032683>
