summaryrefslogtreecommitdiff
path: root/Userland/Applications/Calculator/KeypadValue.h
diff options
context:
space:
mode:
authorcreator1creeper1 <creator1creeper1@airmail.cc>2021-12-19 19:07:53 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-21 13:22:12 -0800
commitcacac7927b714efa8d0881debb85403baac2e650 (patch)
treece532c2ddd30d624d18d843c433c467f315df792 /Userland/Applications/Calculator/KeypadValue.h
parent7ea3d40e1905451da528294e248b8f20e43f0d5f (diff)
downloadserenity-cacac7927b714efa8d0881debb85403baac2e650.zip
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.
Diffstat (limited to 'Userland/Applications/Calculator/KeypadValue.h')
-rw-r--r--Userland/Applications/Calculator/KeypadValue.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Applications/Calculator/KeypadValue.h b/Userland/Applications/Calculator/KeypadValue.h
index 6e69d04016..35364f7ba7 100644
--- a/Userland/Applications/Calculator/KeypadValue.h
+++ b/Userland/Applications/Calculator/KeypadValue.h
@@ -17,6 +17,8 @@ public:
KeypadValue(i64, u8);
KeypadValue(i64);
+ explicit KeypadValue(StringView);
+
KeypadValue operator+(KeypadValue const&);
KeypadValue operator-(KeypadValue const&);
KeypadValue operator*(KeypadValue const&);