mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:47:34 +00:00
Calculator: Use Checked to ensure entered values do not overflow
This replaces the types of m_int_value and m_frac_value with Checked<u64> which makes it possible to check if the value overflowed when entering a digit. If that happens, the digit will just be ignored. This fixes #1263.
This commit is contained in:
parent
7a5407982f
commit
7b53ca5309
2 changed files with 23 additions and 17 deletions
|
@ -30,9 +30,9 @@ public:
|
|||
private:
|
||||
// Internal representation of the current decimal value.
|
||||
bool m_negative { false };
|
||||
long m_int_value { 0 };
|
||||
long m_frac_value { 0 };
|
||||
int m_frac_length { 0 };
|
||||
Checked<u64> m_int_value { 0 };
|
||||
Checked<u64> m_frac_value { 0 };
|
||||
u8 m_frac_length { 0 };
|
||||
// E.g. for -35.004200,
|
||||
// m_negative = true
|
||||
// m_int_value = 35
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue