IEEE FP (was: Questions about NCEG)

Art Boyne boyne at hplvli.HP.COM
Wed May 30 01:02:38 AEST 1990


richard at pantor.UUCP (Richard Sargent) writes:
>> People want hex float so they can represent 7/4096, say, without
>> worrying about flipping a digit and making hash.

>I don't get it. Why would you code some indecipherable
>'magic' fraction rather than just simply declare:
>	float fract = 7.0/4096.0;
>and let the optimizer/compiler turn that into the correct
>constant?

Because algorithms to calculate trigonometric, hyperbolic, etc.,
functions require *exact* values down to the LSB for maximum
accuracy.  I have seen experimentation done with the LSB as part
of efforts to improve accuracy (increase the LSB of this constant,
decrease it on this other constant).  It is easier, and you are
more assured of getting the exact value, if you simply specify
the value in hex rather than writing 1.708984374999999E-4.

Look into articles on numerical analysis and computation of
transcendental functions to learn of the need for exact values.

Art Boyne, boyne at hplvla.hp.com



More information about the Comp.std.c mailing list