Commit Graph

5 Commits

Author SHA1 Message Date
Lucas CHOLLET
7532ef78ad Calculator: Round small number to prevent crash
Small numbers (smaller than 1e-19) can't be displayed in the calculator.
They provoke a division by zero in Keypad::set_value(), as 10^20
overflows.
2022-01-02 15:42:13 +01:00
Lucas CHOLLET
939bf3e864 Calculator: Remove KeypadValue::operator>
This method was declared but not implemented, and will probably never be
useful.
2022-01-02 15:42:13 +01:00
creator1creeper1
4b2b0a4d0e Calculator: Make double construction and conversion private
At this point, the double conversions should really only be
implementation details of the KeypadValue class. Therefore,
the constructor-from double and conversion-operator-to
double of KeypadValue are made private. Instead, the
required functionality is provided by KeypadValue itself.
The internal implementation is still done using doubles.
However, this opens us up to the possibility of having
loss-free square root, inversion and division in the future.
2021-12-22 00:43:13 -08:00
creator1creeper1
cacac7927b Calculator: Construct KeypadValue precisely from the Clipboard contents
Previously, we would use lossy strtod() conversion. This was bad,
especially since we switched from internally storing Calculator
state in a double to storing it in the KeypadValue class
some time ago. This commit adds a constructor for the KeypadValue
class that is not lossy by using strtoll(). It handles numbers
with and without decimal points as well as negative numbers
correctly.
2021-12-21 13:22:12 -08:00
creator1creeper1
97d2a5799e Calculator: Add KeypadValue class
This commit adds a basic KeypadValue class which abstracts away
Keypad's internal representation in a slightly simpler format.
This will allow arithmetic operations in the Calculator to not
lose any precision. In cases where losing precision is necessary,
an explicit conversion operator to double is provided, as well as
an explicit constructor from double.
2021-08-03 19:12:06 +04:30