On Thu, 26 May 2005, Paul Koning wrote:

> >>>>> "Kevin" == Kevin Handy <[EMAIL PROTECTED]> writes:
> 
>  Kevin> But, you are using a number in the range of 2^90, only have 64
>  Kevin> bits for storing the floating point representation, and some
>  Kevin> of that is needed for the exponent.
> 
> Fair enough, so with 64 bit floats you have no right to expect an
> accurate answer for sin(2^90).  However, you DO have a right to expect
> an answer in the range [-1,+1] rather than the 1.2e+27 that Richard
> quoted.  I see no words in the description of
> -funsafe-math-optimizations to lead me to expect such a result.

When I discussed this question with Nick Maclaren a while back after a UK 
C Panel meeting, his view was that for most applications (a) the output 
should be close (within 1 or a few ulp) to the sine/cosine of a value 
close (within 1 or a few ulp) to the floating-point input and (b) sin^2 + 
cos^2 (of any input value) should equal 1 with high precision, but most 
applications (using floating-point values as approximations of 
unrepresentable real numbers) wouldn't care about the answer being close 
to the sine or cosine of the exact real number represented by the 
floating-point value when 1ulp is on the order of 2pi or bigger.  This 
does of course disallow 1.2e+27 as a safe answer for sin or cos to give 
for any input.  (And a few applications may care for stronger degrees of 
accuracy.)

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    [EMAIL PROTECTED] (personal mail)
    [EMAIL PROTECTED] (CodeSourcery mail)
    [EMAIL PROTECTED] (Bugzilla assignments and CCs)

Reply via email to