🚨 fixed more warnings
This commit is contained in:
parent
02b3494711
commit
34f8b4f711
8 changed files with 818 additions and 810 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <array> // array
|
||||
#include <cassert> // assert
|
||||
#include <ciso646> // or, and, not
|
||||
#include <cmath> // signbit, isfinite
|
||||
|
|
@ -49,10 +50,10 @@ struct diyfp // f * 2^e
|
|||
{
|
||||
static constexpr int kPrecision = 64; // = q
|
||||
|
||||
uint64_t f = 0;
|
||||
std::uint64_t f = 0;
|
||||
int e = 0;
|
||||
|
||||
constexpr diyfp(uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
|
||||
constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {}
|
||||
|
||||
/*!
|
||||
@brief returns x - y
|
||||
|
|
@ -97,23 +98,23 @@ struct diyfp // f * 2^e
|
|||
//
|
||||
// = p_lo + 2^64 p_hi
|
||||
|
||||
const uint64_t u_lo = x.f & 0xFFFFFFFF;
|
||||
const uint64_t u_hi = x.f >> 32;
|
||||
const uint64_t v_lo = y.f & 0xFFFFFFFF;
|
||||
const uint64_t v_hi = y.f >> 32;
|
||||
const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
|
||||
const std::uint64_t u_hi = x.f >> 32u;
|
||||
const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
|
||||
const std::uint64_t v_hi = y.f >> 32u;
|
||||
|
||||
const uint64_t p0 = u_lo * v_lo;
|
||||
const uint64_t p1 = u_lo * v_hi;
|
||||
const uint64_t p2 = u_hi * v_lo;
|
||||
const uint64_t p3 = u_hi * v_hi;
|
||||
const std::uint64_t p0 = u_lo * v_lo;
|
||||
const std::uint64_t p1 = u_lo * v_hi;
|
||||
const std::uint64_t p2 = u_hi * v_lo;
|
||||
const std::uint64_t p3 = u_hi * v_hi;
|
||||
|
||||
const uint64_t p0_hi = p0 >> 32;
|
||||
const uint64_t p1_lo = p1 & 0xFFFFFFFF;
|
||||
const uint64_t p1_hi = p1 >> 32;
|
||||
const uint64_t p2_lo = p2 & 0xFFFFFFFF;
|
||||
const uint64_t p2_hi = p2 >> 32;
|
||||
const std::uint64_t p0_hi = p0 >> 32u;
|
||||
const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
|
||||
const std::uint64_t p1_hi = p1 >> 32u;
|
||||
const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
|
||||
const std::uint64_t p2_hi = p2 >> 32u;
|
||||
|
||||
uint64_t Q = p0_hi + p1_lo + p2_lo;
|
||||
std::uint64_t Q = p0_hi + p1_lo + p2_lo;
|
||||
|
||||
// The full product might now be computed as
|
||||
//
|
||||
|
|
@ -124,9 +125,9 @@ struct diyfp // f * 2^e
|
|||
// Effectively we only need to add the highest bit in p_lo to p_hi (and
|
||||
// Q_hi + 1 does not overflow).
|
||||
|
||||
Q += uint64_t{1} << (64 - 32 - 1); // round, ties up
|
||||
Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
|
||||
|
||||
const uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32);
|
||||
const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
|
||||
|
||||
return {h, x.e + y.e + 64};
|
||||
}
|
||||
|
|
@ -139,9 +140,9 @@ struct diyfp // f * 2^e
|
|||
{
|
||||
assert(x.f != 0);
|
||||
|
||||
while ((x.f >> 63) == 0)
|
||||
while ((x.f >> 63u) == 0)
|
||||
{
|
||||
x.f <<= 1;
|
||||
x.f <<= 1u;
|
||||
x.e--;
|
||||
}
|
||||
|
||||
|
|
@ -195,13 +196,13 @@ boundaries compute_boundaries(FloatType value)
|
|||
constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
|
||||
constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
|
||||
constexpr int kMinExp = 1 - kBias;
|
||||
constexpr uint64_t kHiddenBit = uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
|
||||
constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1)
|
||||
|
||||
using bits_type = typename std::conditional< kPrecision == 24, uint32_t, uint64_t >::type;
|
||||
using bits_type = typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
|
||||
|
||||
const uint64_t bits = reinterpret_bits<bits_type>(value);
|
||||
const uint64_t E = bits >> (kPrecision - 1);
|
||||
const uint64_t F = bits & (kHiddenBit - 1);
|
||||
const std::uint64_t bits = reinterpret_bits<bits_type>(value);
|
||||
const std::uint64_t E = bits >> (kPrecision - 1);
|
||||
const std::uint64_t F = bits & (kHiddenBit - 1);
|
||||
|
||||
const bool is_denormal = (E == 0);
|
||||
const diyfp v = is_denormal
|
||||
|
|
@ -304,7 +305,7 @@ constexpr int kGamma = -32;
|
|||
|
||||
struct cached_power // c = f * 2^e ~= 10^k
|
||||
{
|
||||
uint64_t f;
|
||||
std::uint64_t f;
|
||||
int e;
|
||||
int k;
|
||||
};
|
||||
|
|
@ -368,91 +369,92 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
|
|||
// NB:
|
||||
// Actually this function returns c, such that -60 <= e_c + e + 64 <= -34.
|
||||
|
||||
constexpr int kCachedPowersSize = 79;
|
||||
constexpr int kCachedPowersMinDecExp = -300;
|
||||
constexpr int kCachedPowersDecStep = 8;
|
||||
|
||||
static constexpr cached_power kCachedPowers[] =
|
||||
static constexpr std::array<cached_power, 79> kCachedPowers =
|
||||
{
|
||||
{ 0xAB70FE17C79AC6CA, -1060, -300 },
|
||||
{ 0xFF77B1FCBEBCDC4F, -1034, -292 },
|
||||
{ 0xBE5691EF416BD60C, -1007, -284 },
|
||||
{ 0x8DD01FAD907FFC3C, -980, -276 },
|
||||
{ 0xD3515C2831559A83, -954, -268 },
|
||||
{ 0x9D71AC8FADA6C9B5, -927, -260 },
|
||||
{ 0xEA9C227723EE8BCB, -901, -252 },
|
||||
{ 0xAECC49914078536D, -874, -244 },
|
||||
{ 0x823C12795DB6CE57, -847, -236 },
|
||||
{ 0xC21094364DFB5637, -821, -228 },
|
||||
{ 0x9096EA6F3848984F, -794, -220 },
|
||||
{ 0xD77485CB25823AC7, -768, -212 },
|
||||
{ 0xA086CFCD97BF97F4, -741, -204 },
|
||||
{ 0xEF340A98172AACE5, -715, -196 },
|
||||
{ 0xB23867FB2A35B28E, -688, -188 },
|
||||
{ 0x84C8D4DFD2C63F3B, -661, -180 },
|
||||
{ 0xC5DD44271AD3CDBA, -635, -172 },
|
||||
{ 0x936B9FCEBB25C996, -608, -164 },
|
||||
{ 0xDBAC6C247D62A584, -582, -156 },
|
||||
{ 0xA3AB66580D5FDAF6, -555, -148 },
|
||||
{ 0xF3E2F893DEC3F126, -529, -140 },
|
||||
{ 0xB5B5ADA8AAFF80B8, -502, -132 },
|
||||
{ 0x87625F056C7C4A8B, -475, -124 },
|
||||
{ 0xC9BCFF6034C13053, -449, -116 },
|
||||
{ 0x964E858C91BA2655, -422, -108 },
|
||||
{ 0xDFF9772470297EBD, -396, -100 },
|
||||
{ 0xA6DFBD9FB8E5B88F, -369, -92 },
|
||||
{ 0xF8A95FCF88747D94, -343, -84 },
|
||||
{ 0xB94470938FA89BCF, -316, -76 },
|
||||
{ 0x8A08F0F8BF0F156B, -289, -68 },
|
||||
{ 0xCDB02555653131B6, -263, -60 },
|
||||
{ 0x993FE2C6D07B7FAC, -236, -52 },
|
||||
{ 0xE45C10C42A2B3B06, -210, -44 },
|
||||
{ 0xAA242499697392D3, -183, -36 },
|
||||
{ 0xFD87B5F28300CA0E, -157, -28 },
|
||||
{ 0xBCE5086492111AEB, -130, -20 },
|
||||
{ 0x8CBCCC096F5088CC, -103, -12 },
|
||||
{ 0xD1B71758E219652C, -77, -4 },
|
||||
{ 0x9C40000000000000, -50, 4 },
|
||||
{ 0xE8D4A51000000000, -24, 12 },
|
||||
{ 0xAD78EBC5AC620000, 3, 20 },
|
||||
{ 0x813F3978F8940984, 30, 28 },
|
||||
{ 0xC097CE7BC90715B3, 56, 36 },
|
||||
{ 0x8F7E32CE7BEA5C70, 83, 44 },
|
||||
{ 0xD5D238A4ABE98068, 109, 52 },
|
||||
{ 0x9F4F2726179A2245, 136, 60 },
|
||||
{ 0xED63A231D4C4FB27, 162, 68 },
|
||||
{ 0xB0DE65388CC8ADA8, 189, 76 },
|
||||
{ 0x83C7088E1AAB65DB, 216, 84 },
|
||||
{ 0xC45D1DF942711D9A, 242, 92 },
|
||||
{ 0x924D692CA61BE758, 269, 100 },
|
||||
{ 0xDA01EE641A708DEA, 295, 108 },
|
||||
{ 0xA26DA3999AEF774A, 322, 116 },
|
||||
{ 0xF209787BB47D6B85, 348, 124 },
|
||||
{ 0xB454E4A179DD1877, 375, 132 },
|
||||
{ 0x865B86925B9BC5C2, 402, 140 },
|
||||
{ 0xC83553C5C8965D3D, 428, 148 },
|
||||
{ 0x952AB45CFA97A0B3, 455, 156 },
|
||||
{ 0xDE469FBD99A05FE3, 481, 164 },
|
||||
{ 0xA59BC234DB398C25, 508, 172 },
|
||||
{ 0xF6C69A72A3989F5C, 534, 180 },
|
||||
{ 0xB7DCBF5354E9BECE, 561, 188 },
|
||||
{ 0x88FCF317F22241E2, 588, 196 },
|
||||
{ 0xCC20CE9BD35C78A5, 614, 204 },
|
||||
{ 0x98165AF37B2153DF, 641, 212 },
|
||||
{ 0xE2A0B5DC971F303A, 667, 220 },
|
||||
{ 0xA8D9D1535CE3B396, 694, 228 },
|
||||
{ 0xFB9B7CD9A4A7443C, 720, 236 },
|
||||
{ 0xBB764C4CA7A44410, 747, 244 },
|
||||
{ 0x8BAB8EEFB6409C1A, 774, 252 },
|
||||
{ 0xD01FEF10A657842C, 800, 260 },
|
||||
{ 0x9B10A4E5E9913129, 827, 268 },
|
||||
{ 0xE7109BFBA19C0C9D, 853, 276 },
|
||||
{ 0xAC2820D9623BF429, 880, 284 },
|
||||
{ 0x80444B5E7AA7CF85, 907, 292 },
|
||||
{ 0xBF21E44003ACDD2D, 933, 300 },
|
||||
{ 0x8E679C2F5E44FF8F, 960, 308 },
|
||||
{ 0xD433179D9C8CB841, 986, 316 },
|
||||
{ 0x9E19DB92B4E31BA9, 1013, 324 },
|
||||
{
|
||||
{ 0xAB70FE17C79AC6CA, -1060, -300 },
|
||||
{ 0xFF77B1FCBEBCDC4F, -1034, -292 },
|
||||
{ 0xBE5691EF416BD60C, -1007, -284 },
|
||||
{ 0x8DD01FAD907FFC3C, -980, -276 },
|
||||
{ 0xD3515C2831559A83, -954, -268 },
|
||||
{ 0x9D71AC8FADA6C9B5, -927, -260 },
|
||||
{ 0xEA9C227723EE8BCB, -901, -252 },
|
||||
{ 0xAECC49914078536D, -874, -244 },
|
||||
{ 0x823C12795DB6CE57, -847, -236 },
|
||||
{ 0xC21094364DFB5637, -821, -228 },
|
||||
{ 0x9096EA6F3848984F, -794, -220 },
|
||||
{ 0xD77485CB25823AC7, -768, -212 },
|
||||
{ 0xA086CFCD97BF97F4, -741, -204 },
|
||||
{ 0xEF340A98172AACE5, -715, -196 },
|
||||
{ 0xB23867FB2A35B28E, -688, -188 },
|
||||
{ 0x84C8D4DFD2C63F3B, -661, -180 },
|
||||
{ 0xC5DD44271AD3CDBA, -635, -172 },
|
||||
{ 0x936B9FCEBB25C996, -608, -164 },
|
||||
{ 0xDBAC6C247D62A584, -582, -156 },
|
||||
{ 0xA3AB66580D5FDAF6, -555, -148 },
|
||||
{ 0xF3E2F893DEC3F126, -529, -140 },
|
||||
{ 0xB5B5ADA8AAFF80B8, -502, -132 },
|
||||
{ 0x87625F056C7C4A8B, -475, -124 },
|
||||
{ 0xC9BCFF6034C13053, -449, -116 },
|
||||
{ 0x964E858C91BA2655, -422, -108 },
|
||||
{ 0xDFF9772470297EBD, -396, -100 },
|
||||
{ 0xA6DFBD9FB8E5B88F, -369, -92 },
|
||||
{ 0xF8A95FCF88747D94, -343, -84 },
|
||||
{ 0xB94470938FA89BCF, -316, -76 },
|
||||
{ 0x8A08F0F8BF0F156B, -289, -68 },
|
||||
{ 0xCDB02555653131B6, -263, -60 },
|
||||
{ 0x993FE2C6D07B7FAC, -236, -52 },
|
||||
{ 0xE45C10C42A2B3B06, -210, -44 },
|
||||
{ 0xAA242499697392D3, -183, -36 },
|
||||
{ 0xFD87B5F28300CA0E, -157, -28 },
|
||||
{ 0xBCE5086492111AEB, -130, -20 },
|
||||
{ 0x8CBCCC096F5088CC, -103, -12 },
|
||||
{ 0xD1B71758E219652C, -77, -4 },
|
||||
{ 0x9C40000000000000, -50, 4 },
|
||||
{ 0xE8D4A51000000000, -24, 12 },
|
||||
{ 0xAD78EBC5AC620000, 3, 20 },
|
||||
{ 0x813F3978F8940984, 30, 28 },
|
||||
{ 0xC097CE7BC90715B3, 56, 36 },
|
||||
{ 0x8F7E32CE7BEA5C70, 83, 44 },
|
||||
{ 0xD5D238A4ABE98068, 109, 52 },
|
||||
{ 0x9F4F2726179A2245, 136, 60 },
|
||||
{ 0xED63A231D4C4FB27, 162, 68 },
|
||||
{ 0xB0DE65388CC8ADA8, 189, 76 },
|
||||
{ 0x83C7088E1AAB65DB, 216, 84 },
|
||||
{ 0xC45D1DF942711D9A, 242, 92 },
|
||||
{ 0x924D692CA61BE758, 269, 100 },
|
||||
{ 0xDA01EE641A708DEA, 295, 108 },
|
||||
{ 0xA26DA3999AEF774A, 322, 116 },
|
||||
{ 0xF209787BB47D6B85, 348, 124 },
|
||||
{ 0xB454E4A179DD1877, 375, 132 },
|
||||
{ 0x865B86925B9BC5C2, 402, 140 },
|
||||
{ 0xC83553C5C8965D3D, 428, 148 },
|
||||
{ 0x952AB45CFA97A0B3, 455, 156 },
|
||||
{ 0xDE469FBD99A05FE3, 481, 164 },
|
||||
{ 0xA59BC234DB398C25, 508, 172 },
|
||||
{ 0xF6C69A72A3989F5C, 534, 180 },
|
||||
{ 0xB7DCBF5354E9BECE, 561, 188 },
|
||||
{ 0x88FCF317F22241E2, 588, 196 },
|
||||
{ 0xCC20CE9BD35C78A5, 614, 204 },
|
||||
{ 0x98165AF37B2153DF, 641, 212 },
|
||||
{ 0xE2A0B5DC971F303A, 667, 220 },
|
||||
{ 0xA8D9D1535CE3B396, 694, 228 },
|
||||
{ 0xFB9B7CD9A4A7443C, 720, 236 },
|
||||
{ 0xBB764C4CA7A44410, 747, 244 },
|
||||
{ 0x8BAB8EEFB6409C1A, 774, 252 },
|
||||
{ 0xD01FEF10A657842C, 800, 260 },
|
||||
{ 0x9B10A4E5E9913129, 827, 268 },
|
||||
{ 0xE7109BFBA19C0C9D, 853, 276 },
|
||||
{ 0xAC2820D9623BF429, 880, 284 },
|
||||
{ 0x80444B5E7AA7CF85, 907, 292 },
|
||||
{ 0xBF21E44003ACDD2D, 933, 300 },
|
||||
{ 0x8E679C2F5E44FF8F, 960, 308 },
|
||||
{ 0xD433179D9C8CB841, 986, 316 },
|
||||
{ 0x9E19DB92B4E31BA9, 1013, 324 },
|
||||
}
|
||||
};
|
||||
|
||||
// This computation gives exactly the same results for k as
|
||||
|
|
@ -466,10 +468,9 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
|
|||
|
||||
const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
|
||||
assert(index >= 0);
|
||||
assert(index < kCachedPowersSize);
|
||||
static_cast<void>(kCachedPowersSize); // Fix warning.
|
||||
assert(static_cast<std::size_t>(index) < kCachedPowers.size());
|
||||
|
||||
const cached_power cached = kCachedPowers[index];
|
||||
const cached_power cached = kCachedPowers[static_cast<std::size_t>(index)];
|
||||
assert(kAlpha <= cached.e + e + 64);
|
||||
assert(kGamma >= cached.e + e + 64);
|
||||
|
||||
|
|
@ -480,7 +481,7 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
|
|||
For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k.
|
||||
For n == 0, returns 1 and sets pow10 := 1.
|
||||
*/
|
||||
inline int find_largest_pow10(const uint32_t n, uint32_t& pow10)
|
||||
inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10)
|
||||
{
|
||||
// LCOV_EXCL_START
|
||||
if (n >= 1000000000)
|
||||
|
|
@ -536,8 +537,8 @@ inline int find_largest_pow10(const uint32_t n, uint32_t& pow10)
|
|||
}
|
||||
}
|
||||
|
||||
inline void grisu2_round(char* buf, int len, uint64_t dist, uint64_t delta,
|
||||
uint64_t rest, uint64_t ten_k)
|
||||
inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta,
|
||||
std::uint64_t rest, std::uint64_t ten_k)
|
||||
{
|
||||
assert(len >= 1);
|
||||
assert(dist <= delta);
|
||||
|
|
@ -598,8 +599,8 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
assert(M_plus.e >= kAlpha);
|
||||
assert(M_plus.e <= kGamma);
|
||||
|
||||
uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e)
|
||||
uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e)
|
||||
std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e)
|
||||
std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e)
|
||||
|
||||
// Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0):
|
||||
//
|
||||
|
|
@ -608,10 +609,10 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
// = ((p1 ) * 2^-e + (p2 )) * 2^e
|
||||
// = p1 + p2 * 2^e
|
||||
|
||||
const diyfp one(uint64_t{1} << -M_plus.e, M_plus.e);
|
||||
const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
|
||||
|
||||
auto p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
||||
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
||||
auto p1 = static_cast<std::uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
||||
std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
||||
|
||||
// 1)
|
||||
//
|
||||
|
|
@ -619,7 +620,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
|
||||
assert(p1 > 0);
|
||||
|
||||
uint32_t pow10;
|
||||
std::uint32_t pow10;
|
||||
const int k = find_largest_pow10(p1, pow10);
|
||||
|
||||
// 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1)
|
||||
|
|
@ -647,8 +648,8 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
// M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k)
|
||||
// pow10 = 10^(n-1) <= p1 < 10^n
|
||||
//
|
||||
const uint32_t d = p1 / pow10; // d = p1 div 10^(n-1)
|
||||
const uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1)
|
||||
const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1)
|
||||
const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1)
|
||||
//
|
||||
// M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e
|
||||
// = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e)
|
||||
|
|
@ -673,7 +674,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
// Note:
|
||||
// Since rest and delta share the same exponent e, it suffices to
|
||||
// compare the significands.
|
||||
const uint64_t rest = (uint64_t{p1} << -one.e) + p2;
|
||||
const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
|
||||
if (rest <= delta)
|
||||
{
|
||||
// V = buffer * 10^n, with M- <= V <= M+.
|
||||
|
|
@ -689,7 +690,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
//
|
||||
// 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e
|
||||
//
|
||||
const uint64_t ten_n = uint64_t{pow10} << -one.e;
|
||||
const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
|
||||
grisu2_round(buffer, length, dist, delta, rest, ten_n);
|
||||
|
||||
return;
|
||||
|
|
@ -753,8 +754,8 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
//
|
||||
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
|
||||
const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e
|
||||
const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e
|
||||
//
|
||||
// M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e
|
||||
// = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e))
|
||||
|
|
@ -794,7 +795,7 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
|||
//
|
||||
// 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e
|
||||
//
|
||||
const uint64_t ten_m = one.f;
|
||||
const std::uint64_t ten_m = one.f;
|
||||
grisu2_round(buffer, length, dist, delta, p2, ten_m);
|
||||
|
||||
// By construction this algorithm generates the shortest possible decimal
|
||||
|
|
@ -929,7 +930,7 @@ inline char* append_exponent(char* buf, int e)
|
|||
*buf++ = '+';
|
||||
}
|
||||
|
||||
auto k = static_cast<uint32_t>(e);
|
||||
auto k = static_cast<std::uint32_t>(e);
|
||||
if (k < 10)
|
||||
{
|
||||
// Always print at least two digits in the exponent.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue