Floating point exceptions

Tim Rowledge rowledge at interval.com
Sat Mar 20 19:59:03 UTC 1999


Thanks for all the suggestions folks.

I've eventually found a (probable) solution, by setting some flags in the
floating point status register. If I turn off the trap enable bits that are
normally set on by the C runtime system, I appear to get appropriate
infinity/-0.0/etc responses.
Just as FYI for anyone interested in things like this, I'll explain some
more:-
 the C library manual explains about using 'signal(SIGFPE, __SIG_IGN)' and
so on, but all that did was ignore the exception from the FPE and get a
wrong result :-(
 said manual also explains that the default setting of the status is to
allow exceptions for overflow, underflow, invalid operation and inexact
result.
 it doesn't explain how to handle the da&*^&ed exceptions in any meaningful
way.

Don'tcha just love manuals?

Anyway, it seems to work ok for now. Oh, the way I set the FP status
register might amuse you:- I have a simple ARM assembler class that can
write the instruction bits in memory and then execute the new function. I
didn't think it would be so immediately useful...

happy tim


-- 
Useful random insult:- If brains were taxed, he'd get a rebate.
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