1
0
mirror of https://github.com/nlohmann/json synced 2024-11-10 06:20:06 +00:00

Change macros to numeric_limits #1483

This commit is contained in:
Ferenc Nasztanovics 2019-03-13 23:42:46 +01:00
parent 0c65ba960e
commit 0067ea8f9e
2 changed files with 2 additions and 2 deletions

View File

@ -751,7 +751,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
// = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e
// = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e
//
assert(p2 <= UINT64_MAX / 10);
assert(p2 <= std::numeric_limits<std::uint64_t>::max() / 10);
p2 *= 10;
const uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e
const uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e

View File

@ -10579,7 +10579,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
// = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e
// = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e
//
assert(p2 <= UINT64_MAX / 10);
assert(p2 <= std::numeric_limits<std::uint64_t>::max() / 10);
p2 *= 10;
const uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e
const uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e