Bug #9706 Precision Math: Sin Function returns incorrect results when used with pi()

Submitted: 7 Apr 2005 8:28 Modified: 7 Apr 2005 16:53
Reporter: Disha Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.3 Beta OS:Windows (Windows 2003)
Assigned to: CPU Architecture:Any

[7 Apr 2005 8:28] Disha
Description:
Using Sin function with any parameter , gives incorrect result

How to repeat:
1. Select Sin(90), Sin(pi(30))//

Actual Result:

+------------------+----------------------+
| sin(90)          | sin(pi())            |
+------------------+----------------------+
| 0.89399666360056 | 1.2246063538224e-016 |
+------------------+----------------------+
1 row in set (0.00 sec)

Expected result:
+------------------+----------------------+
| sin(90)          | sin(pi())            |
+------------------+----------------------+
| 1               | 0            |
+------------------+----------------------+
1 row in set (0.00 sec)
[7 Apr 2005 15:16] Disha
The results are returned in radians. Hence the updated expected results are:

+------------------+----------------------+
| sin(90)          | sin(pi())            |
+------------------+----------------------+
| 0.89399666360056 | 0               |
+------------------+----------------------+
1 row in set (0.00 sec)
[7 Apr 2005 16:53] Jorge del Conde
Hi,

sin() returns a approximate number (double). for approximate numbers, exact comparison does not work. instead of f1 = f2, one should use abs(f1 - f2) < epsilon method of comparison (used in floating point calculations).

Also, sin() is not exact, and pi() is double, so having:

sin(pi()) == 1.2246063538224e-16 is the expected result in this case.

--
Jorge

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.