| Summary: | sin(30) does not display correct value | ||
|---|---|---|---|
| Product: | Group37 | Reporter: | PAN Zhenyuan <pzyhihihi> |
| Component: | calculation operation | Assignee: | feiwu25-c |
| Status: | RESOLVED FIXED | ||
| Severity: | minor | CC: | tommyhonym |
| Priority: | --- | ||
| Version: | unspecified | ||
| Hardware: | PC | ||
| OS: | Windows | ||
|
Description
PAN Zhenyuan
2020-11-07 16:03:46 HKT
Overview: tan(90) will cause the program to get stuck Step to reproduce: 1) Start the calculator 2) Enter 2 to enter Normal Calculation 3) Enter 2 to input algo 4) Enter sin(30) 5) Press Enter to continue Expected Result: sin(30) = 0.5 Actual Result: sin(30) = 0.4999999999 Build Date & Hardware: 07-11-2020 on Window 10.0.18363 (In reply to PAN Zhenyuan from comment #1) > Overview: > tan(90) will cause the program to get stuck > > Step to reproduce: > 1) Start the calculator > 2) Enter 2 to enter Normal Calculation > 3) Enter 2 to input algo > 4) Enter sin(30) > 5) Press Enter to continue > > Expected Result: > sin(30) = 0.5 > > Actual Result: > sin(30) = 0.4999999999 > > > Build Date & Hardware: > 07-11-2020 on Window 10.0.18363 It's a precision problem of Java floating numbers. I will try to fix it using math libraries. Fixed using floating precision tricks. Reason:Floating numbers can't be very precise when dealing with very small numbers. Solution:I multiply the floating number by a large number floor it, and then devide it by the same number. |