Floating point puzzle

Rob Carriere rob at kaa.eng.ohio-state.edu
Mon Aug 8 07:13:25 AEST 1988


In article <3117 at emory.uucp> riddle at emory.uucp (Larry Riddle) writes:
> [ C program on Sun-4 gives strange single precision results, to wit,
>   the results look like mutilated doubles ]

I don't *know*, but you might want to look into what your floating
point hardware does.  Most floating point hardware I know of, only
implements IEEE to whatever extent was convenient.  Specifically, many
of these devices leave results hanging around in the (extended
precision) floating registers if at all possible.  This means that you
may get more precision than you asked for, ie probably your results
really are doubles, despite you asking for singles.  This would also
explain why you see truncated rather than rounded doubles: you are
doing the truncation manually when you ask for the hex output.

Note that this behaviour, while not IEEE, is ANSI C acceptable.

Rob Carriere



More information about the Comp.std.c mailing list