From cacac7927b714efa8d0881debb85403baac2e650 Mon Sep 17 00:00:00 2001 From: creator1creeper1 Date: Sun, 19 Dec 2021 19:07:53 +0100 Subject: 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. --- Userland/Applications/Calculator/KeypadValue.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Userland/Applications/Calculator/KeypadValue.h') 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&); -- cgit v1.2.3