Sun FPU question

Chris Torek chris at mimsy.UUCP
Tue Mar 7 14:42:21 AEST 1989


In article <92698 at sun.uucp> khb at fatcity.Sun.COM
(Keith Bierman Sun Tactical Engineering) writes:
>To get the behavior you desire (if you have SunOS 4.+), add the following
>line of code to your main program.
>
>	i = ieee_handler("set","common",SIGFPE_ABORT)
>
>Now your sun will act like a pre-ieee machine, and dump core when
>anything nasty happens.

I would prefer that this be the default behaviour, and that a call
should be required to get standard IEEE operation.  This has the
advantage of producing a compile-time (or link-time) error when the
program is moved to another machine which does not support IEEE
arithmetic.  Defaults should always be the most useful mode, but `most
useful' depends on the application and the programmer, and having
experienced porting problems, I am biased towards `most useful' =>
`least likely to surprise'.

>Of course, you can get much better results by being clever and letting
>nature take its course, and check in key places....

Assuming, of course, that you are willing to restrict yourself to IEEE-
capable machines.  This is not an unreasonable binding: F.P. arithmetic
tends to be quite machine dependent, and IEEE is probably the best
available compromise.  But whatever you choose, it should be made clear.
Simply assuming that IEEE behaviour will occur is dangerous.  Commenting
that it is required is better, but still leads to surprises (many people
never look at the code they use, and most should never *have* to).
Thus, for my own protection, I would like to have to call a function,
or set a compile-time switch or similar, to get IEEE-compliant arithmetic.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list