Bug 1015 : sin() cos() [with PI] return values not in range (-1,1)
Last modified: 2008-11-18 07:22




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
pajaja
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2008-11-18 07:06
When using sin() with some floating point numbers like PI, TWO_PI, 4*PI
etc. [also radians(180)]
and cos() with PI_HALF, 3*PI_HALF, etc. i get strange FP numbers such as:

-4.371139E-8
-8.742278E-8
1.7484555E-7
1.1924881E-8
-8.742278E-8

and the correct result should be 0. I noticed that this works only when fp
number has more than 2 numbers after a decimal point.
I couldn't find any reported bugs related to that, so maybe i didn't get
something right?

Tried on win r#0148 and linux r#0156.
Additional Comment #1 From fry 2008-11-18 07:09
No, those values are quite in range; that E-8 and E-7 at the end means that
these values have several zeros in front of them.

Floating point numbers don't have perfect accuracy, so you're just seeing
some rounding error. Instead of 0, the value comes out at
-0.00000000371139. It's a tradeoff for efficiency and speed.
Additional Comment #2 From pajaja 2008-11-18 07:22
Omg, can't believe i missed the negative sign of exponent... Sorry :/