I am writing an (almost) IEEE 854 compliant floating point implementation in TeX (which only has support for 32-bit integers). This standard only specifies the result of +
, -
, *
, /
, comparison, remainder, and sqrt
: for those operations, the result should be identical to rounding the exact result to a representable number (according to the rounding mode).
I seem to recall that IEEE specifies that transcendental functions (sin
, exp
...) should yield faithful results (in the default round-to-nearest mode, they should output one of the two representable numbers surrounding the exact result). Computing the sine of small numbers is rather straightforward: shift by a multiple of 2*pi to obtain a number in the range [0,2*pi], then do some more work to reduce the range to [0,pi/4], and use a Taylor series.
Now assume that I want to compute sin(1e300). For that I would need to find 1e300 modulo 2*pi. That requires to know 300 (316?) decimals of pi, because with only 16 decimals, the result would have no significance whatsoever (in particular, it souldn't be faithful).
Is there a standard on what the result of sin(1e300)
and similar very large numbers should be?
What do other floating point implementations do?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…