From a641e4315fc3f9185338183ea559fe5be3c1082e Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Fri, 1 Jan 2021 23:57:34 -0500 Subject: [PATCH] Variant: Support 64-bit numeric values Closes #2101. --- src/Variant.cpp | 14 +++++++------- src/Variant.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Variant.cpp b/src/Variant.cpp index c9cb54020..fdd096db1 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -1838,7 +1838,7 @@ void Variant::cast (const enum type new_type) case type_string: { char temp[24]; - snprintf (temp, 24, "%d", _integer); + snprintf (temp, 24, "%lld", _integer); _string = temp; } break; @@ -1851,7 +1851,7 @@ void Variant::cast (const enum type new_type) switch (new_type) { case type_boolean: _bool = _real == 0.0 ? false : true; break; - case type_integer: _integer = (int) _real; break; + case type_integer: _integer = (long long) _real; break; case type_real: break; case type_string: { @@ -1875,9 +1875,9 @@ void Variant::cast (const enum type new_type) _string == "0.0") ? false : true; break; case type_integer: - _integer = (int) strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10)); + _integer = (long long) strtol (_string.c_str (), nullptr, (_string.substr (0, 2) == "0x" ? 16 : 10)); break; - case type_real: _real = strtod (_string.c_str (), nullptr); break; + case type_real: _real = strtod (_string.c_str (), nullptr); break; case type_string: break; case type_date: { @@ -1926,7 +1926,7 @@ void Variant::cast (const enum type new_type) switch (new_type) { case type_boolean: _bool = _date != 0 ? true : false; break; - case type_integer: _integer = (int) _date; break; + case type_integer: _integer = (long long) _date; break; case type_real: _real = static_cast(_date); break; case type_string: _string = (std::string) *this; break; case type_date: break; @@ -1938,7 +1938,7 @@ void Variant::cast (const enum type new_type) switch (new_type) { case type_boolean: _bool = _duration != 0 ? true : false; break; - case type_integer: _integer = (int) _duration; break; + case type_integer: _integer = (long long) _duration; break; case type_real: _real = static_cast(_duration); break; case type_string: _string = (std::string) *this; break; case type_date: _date = _duration; break; @@ -1973,7 +1973,7 @@ bool Variant::get_bool () const } //////////////////////////////////////////////////////////////////////////////// -int Variant::get_integer () const +long long Variant::get_integer () const { return _integer; } diff --git a/src/Variant.h b/src/Variant.h index 05f1f575b..ff6da18fd 100644 --- a/src/Variant.h +++ b/src/Variant.h @@ -99,7 +99,7 @@ public: bool trivial () const; bool get_bool () const; - int get_integer () const; + long long get_integer () const; double get_real () const; const std::string& get_string () const; time_t get_date () const; @@ -108,7 +108,7 @@ public: private: enum type _type {type_boolean}; bool _bool {false}; - int _integer {0}; + long long _integer {0}; double _real {0.0}; std::string _string {""}; time_t _date {0};