From owner-freebsd-hackers Tue Jan 4 6:49:29 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from knight.cons.org (knight.cons.org [194.233.237.195]) by hub.freebsd.org (Postfix) with ESMTP id 9E962152AA for ; Tue, 4 Jan 2000 06:49:25 -0800 (PST) (envelope-from cracauer@knight.cons.org) Received: (from cracauer@localhost) by knight.cons.org (8.9.3/8.9.3) id PAA05472; Tue, 4 Jan 2000 15:49:10 +0100 (CET) Date: Tue, 4 Jan 2000 15:49:09 +0100 From: Martin Cracauer To: Kelly Yancey Cc: Martin Cracauer , Markus Holmberg , freebsd-hackers@FreeBSD.ORG Subject: Re: Should -mieee-fp equal fpsetmask(0) to avoid SIGFPE on FreeBSD? Message-ID: <20000104154909.A5444@cons.org> References: <20000104121459.A8959@cons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: ; from kbyanc@posi.net on Tue, Jan 04, 2000 at 09:36:59AM -0500 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In , Kelly Yancey wrote: > > > > #include > > #include > > #include > > > > int main(void) > > { > > double bla; > > int foo; > > > > fpsetmask(0); > > bla = (double)INT_MAX + 1.0; > > foo = bla; > > > > printf("Result: %d\n", foo); > > > > return 0; > > } > > > > Result: -2147483648 > > > > > > Actually, this the same value (INT_MIN = -2147483648) you would get if > you just said foo = INT_MAX + 1 since in 2's complement notation INT_MIN = > INT_MAX + 1. Try bla = (double)INT_MAX * 13.0; >It definately isn't garbage. No, you're mislead by my example that happens to choose a value combination that *looks* explainable. It in reality the results of float->int conversions without range check are neither explainable nor can you depend on them. They are just garbage when you disabled exceptions. You can draw some conclusions what happens on integer aritmetic overflows (when you know the size of the operands). That is very different from the float->int conversion results, which do not behave in the usual integer overflow manner (although my first example looked like they would). Martin -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer/ Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message