Floating point exceptions
Jarvis, Robert P.
Jarvisb at timken.com
Mon Mar 22 12:55:09 UTC 1999
Given some of the oddities observed when the Float>>raisedTo: controversy
arose awhile back, I don't think it's surprising to find that floating point
calculations behave differently on different platforms. Irritating,
aggravating, infuriating, and annoying certainly, but not surprising. :-}
On NT I find that if I inspect the result of
1.7976931348623159e308 * 1.7976931348623159e308
(which is the same as MaxVal * MaxVal) I get Infinity. I think this means
that the floating point code in the image somewhere is (correctly)
determining that it's getting back an IEEE infinity, and is then creating a
reference to the Infinity constant. Curiouser and curiouser...
I suspect that the VM you're working with isn't trapping floating point
errors (SIGFPE?), and thus the error is being kicked to the operating system
with predictable results. Hunt around for a call to signal with SIGFPE as
the signal name. It may be that it's not there, or that the signal handler
isn't handling the errors correctly. Just a thought.
<fifty-percent-joke>
I think the obvious thing to do is to get rid of Floats. They cause more
trouble than they're worth.
</fifty-percent-joke>
Bob Jarvis
The Timken Company
> -----Original Message-----
> From: Tim Rowledge [SMTP:rowledge at interval.com]
> Sent: Friday, March 19, 1999 5:17 PM
> To: Squeak mailinglist
> Subject: Floating point exceptions
>
> I'm having trouble with floating point class initialization. Hopefully
> somebody
> reading this is knowledgable enough to help me solve the problem.
>
> Float class>initialize creates a bunch of constants like Pi, MaxVal and so
> on.
> No problem there, but attempting to execute things like
> Infinity _ MaxVal * MaxVal
> causes a floating point exception and program exit.
>
> On the face of it, I'm not surprised; after all, we've just carefully
> found the
> maximum possible float and now we square it. Of course it overflows!
> However,
> Sq on W95 does not cause an exception, and presumably nor does Mac since
> I've
> heard no complaints from Mac users filing in the recent updates
> (B3DExponentTable causes a similar exception).
>
> Is it really the case that the float libraries just ignore errors like
> overflow? Is there some switch being set somewhere in the PC/MAc platform
> code
> that I haven't seen? Should Sq code assume that it is ok to square Float
> MaxVal? Does ANSI/IEEE allow for this? Do unix VMs have similar trouble?
>
> tim
>
> --
> Software is mind work. Having the right frame of mind is essential.
> Tim Rowledge: rowledge at interval.com (w) +1 (650) 842-6110 (w)
> tim at sumeru.stanford.edu (h) <http://sumeru.stanford.edu/tim>
More information about the Squeak-dev
mailing list
|