-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
C-C++Code - Pull requests that update C++ code.Code - Pull requests that update C++ code.T-BugType - Bug and unexpected behavior.Type - Bug and unexpected behavior.T-ImprovementType - Improvements to components.Type - Improvements to components.
Milestone
Description
Describe the bug
There is a calculation error caused by incorrect detection of isPowerOfTen(). isPowerOfTen() incorrectly assumes a decimal like 0.1111 to be a power of 10, while it is not. This leads to a chain of errors, specifically multiply() trying to simplify the calculation by moving decimal places, leading to a wrong result.
To Reproduce
Steps to reproduce the behavior:
- Run the
calc_multiplyprogram with arguments-4.4000000000,0.11111111. - Outputs
0.44, with a note showing it has done the calculation by moving decimal places.
Expected behavior
Output should be -0.488888884, and should not be done by moving decimal places.
Screenshots
$ src/calc_multiply -4.4000000000 0.111111111111
◉calc::multiply - INFO: -4.4000000000 × 0.111111111111 = -0.48888888888840000000000000000000000000000000000000
4 4
× 0 1 1 1 1 1 1 1 1 1 1 1 1
_________________________________________________
4 4 0 0 0 0 0 0 0 0 0 0 0
4 4 0 0 0 0 0 0 0 0 0 0
4 4 0 0 0 0 0 0 0 0 0
4 4 0 0 0 0 0 0 0 0
4 4 0 0 0 0 0 0 0
4 4 0 0 0 0 0 0
4 4 0 0 0 0 0
4 4 0 0 0 0
4 4 0 0 0
4 4 0 0
4 4 0
4 4
_________________________________________________
0 0 4 8 8 8 8 8 8 8 8 8 8 8 4
∴ -4.4000000000 × 0.111111111111 = -0.48888888888840000000000000000000000000000000000000
OS
- All OSs are affected
Additional context
None yet
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-C++Code - Pull requests that update C++ code.Code - Pull requests that update C++ code.T-BugType - Bug and unexpected behavior.Type - Bug and unexpected behavior.T-ImprovementType - Improvements to components.Type - Improvements to components.
Projects
Status
Done