From owner-freebsd-hackers Fri Dec 24 2:49:48 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from axl.noc.iafrica.com (axl.noc.iafrica.com [196.31.1.175]) by hub.freebsd.org (Postfix) with ESMTP id 8725D14CFA for ; Fri, 24 Dec 1999 02:49:41 -0800 (PST) (envelope-from sheldonh@axl.noc.iafrica.com) Received: from sheldonh (helo=axl.noc.iafrica.com) by axl.noc.iafrica.com with local-esmtp (Exim 3.11 #1) id 121SJf-000Jsr-00; Fri, 24 Dec 1999 12:51:23 +0200 From: Sheldon Hearn To: Ben Smithurst Cc: Bosko Milekic , hackers@FreeBSD.ORG Subject: Re: SIGFPE on arithmetic overflow In-reply-to: Your message of "Fri, 24 Dec 1999 10:37:35 GMT." <19991224103735.A649@strontium.scientia.demon.co.uk> Date: Fri, 24 Dec 1999 12:51:23 +0200 Message-ID: <76436.946032683@axl.noc.iafrica.com> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include 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