[Bug c/43405] sinl is not computed correctly

2010-03-19 Thread eli dot osherovich at gmail dot com


--- Comment #9 from eli dot osherovich at gmail dot com  2010-03-19 13:29 
---
(In reply to comment #7)
> Subject: Re:  sinl is not computed correctly
> 
> On Thu, 18 Mar 2010, bangerth at gmail dot com wrote:
> 
> > Also: 1e22 is not exactly representable as a floating point number. By
> 
> 5**22 is smaller than 2**53, so 1e22 (= 5**22 * 2**22) *is* exactly 
> representable in double or formats with more bits than double.
> 
1e22 is not representable exactly in the binary format. Not because of its
magnitude, just because most numbers cannot be represented exactly in
computers.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43405



[Bug c/43405] sinl is not computed correctly

2010-03-19 Thread eli dot osherovich at gmail dot com


--- Comment #8 from eli dot osherovich at gmail dot com  2010-03-19 13:27 
---
(In reply to comment #6)
> Also: 1e22 is not exactly representable as a floating point number. By
> consequence, 1e22 is different numbers when stored as a double or a
> long double, and we should expect different results when applying the
> sine to it.
> 
> W.
> 
This is *not* a problem of binary representation. I tried to use exactly the
same argument (one time double, another time *promoted* to long double). The
function is not implemented correctly, or, at least for some numbers in legal
range.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43405



[Bug c/43405] sinl is not computed correctly

2010-03-17 Thread eli dot osherovich at gmail dot com


--- Comment #5 from eli dot osherovich at gmail dot com  2010-03-17 18:05 
---
The very same code compiled by the Intel C compiler runs as expected.
Moreover, the prototype of sinl is as  follows

long double sinl(long double x);

and 1e22 definitely withing the bounds  of long double.


(In reply to comment #4)
> more details...
> 
> intel (24319101.pdf) manual describe requirements for fsin opcode:
> 
> "Calculates the sine of the source operand in register ST(0) and stores
>  the result in ST(0). The source operand must be given in radians and must
>  be within the range −2^63 to +2^63."
> 
> the 1e+22 is greater than allowed 2^63 ~ 9.22e+18.
> 
> so this bug is rejected by hardware ;)
> 

(In reply to comment #4)
> more details...
> 
> intel (24319101.pdf) manual describe requirements for fsin opcode:
> 
> "Calculates the sine of the source operand in register ST(0) and stores
>  the result in ST(0). The source operand must be given in radians and must
>  be within the range −2^63 to +2^63."
> 
> the 1e+22 is greater than allowed 2^63 ~ 9.22e+18.
> 
> so this bug is rejected by hardware ;)
> 

(In reply to comment #4)
> more details...
> 
> intel (24319101.pdf) manual describe requirements for fsin opcode:
> 
> "Calculates the sine of the source operand in register ST(0) and stores
>  the result in ST(0). The source operand must be given in radians and must
>  be within the range −2^63 to +2^63."
> 
> the 1e+22 is greater than allowed 2^63 ~ 9.22e+18.
> 
> so this bug is rejected by hardware ;)
> 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43405



[Bug c/43405] sinl is not computed correctly

2010-03-17 Thread eli dot osherovich at gmail dot com


--- Comment #1 from eli dot osherovich at gmail dot com  2010-03-17 15:29 
---
Created an attachment (id=20131)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20131&action=view)
testcase as a standalone file


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43405



[Bug c/43405] New: sinl is not computed correctly

2010-03-17 Thread eli dot osherovich at gmail dot com
sinl (and probably others) are not computed correctly. At least for large
inputs.

Please consider the following simple testcase:

$ cat sintest.c

#include 
#include 

int
main (void) {
  double arg = 1e22;
  long double larg = 1e22L;


  printf("double precision: sin(1e22) = %.16lf\n", sin(arg));
  printf("quad precison: sin(1e22)=%.16Lf\n", sinl(larg));

  return 0;
}


$gcc sintest.c
$./a.out
double precision: sin(1e22) = -0.8522008497671888
quad precison: sin(1e22)=0.4626130407646018


This behavior is demonstrated by gcc-4.4.3 and gcc-4.5 (current snapshot)

I am using ubuntu on a 64 bit linux machine (intel). 

However, the same results were obtained on different machines.


-- 
   Summary: sinl is not computed correctly
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: critical
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: eli dot osherovich at gmail dot com
  GCC host triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43405