TiDB Trigonometric Function Precision Loss: SIN(x+2π) ≠ SIN(x) Due to Floating-Point Calculation Inconsistencies
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```
select sin(0);
select sin(0+2*PI());
```
### 2. What did you expect to see? (Required)
the values should be the same absolutely
mysql> select sin(0+2*PI());
+------------------------+
| sin(0+2*PI()) |
+------------------------+
| -2.449293598294703e-16 |
+------------------------+
1 row in set (0.00 sec)
mysql> select sin(0);
+--------+
| sin(0) |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
### 3. What did you see instead (Required)
mysql> select sin(0+2*PI());
+------------------------+
| sin(0+2*PI()) |
+------------------------+
| -2.449293598294703e-16 |
+------------------------+
1 row in set (0.00 sec)
mysql> select sin(0);
+--------+
| sin(0) |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
### 4. What is your TiDB version? (Required)
mysql> select tidb_version();
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.5.1
Edition: Community
Git Commit Hash: 7d16cc79e81bbf573124df3fd9351c26963f3e70
Git Branch: heads/refs/tags/v7.5.1
UTC Build Time: 2024-02-27 14:28:32
GoVersion: go1.21.6
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Contributor guide
Assessment
This issue has not been assessed yet.