Skip to content

Commit a2a7d97

Browse files
committed
Use std::numeric_limits instead of macros
1 parent fc85fbe commit a2a7d97

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/rapidjson/internal/strtod.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "biginteger.h"
2020
#include "diyfp.h"
2121
#include "pow10.h"
22+
#include <limits>
2223

2324
RAPIDJSON_NAMESPACE_BEGIN
2425
namespace internal {
@@ -228,18 +229,18 @@ inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t
228229
if (StrtodFast(d, p, &result))
229230
return result;
230231

231-
RAPIDJSON_ASSERT(length <= INT_MAX);
232+
RAPIDJSON_ASSERT(length <= std::numeric_limits<int>::max());
232233
int dLen = static_cast<int>(length);
233234

234235
RAPIDJSON_ASSERT(length >= decimalPosition);
235-
RAPIDJSON_ASSERT(length - decimalPosition <= INT_MAX);
236+
RAPIDJSON_ASSERT(length - decimalPosition <= std::numeric_limits<int>::max());
236237
int dExpAdjust = static_cast<int>(length - decimalPosition);
237238

238-
RAPIDJSON_ASSERT(exp >= INT_MIN + dExpAdjust);
239+
RAPIDJSON_ASSERT(exp >= std::numeric_limits<int>::min() + dExpAdjust);
239240
int dExp = exp - dExpAdjust;
240241

241242
// Make sure length+dExp does not overflow
242-
RAPIDJSON_ASSERT(dExp <= INT_MAX - dLen);
243+
RAPIDJSON_ASSERT(dExp <= std::numeric_limits<int>::max() - dLen);
243244

244245
// Trim leading zeros
245246
while (dLen > 0 && *decimals == '0') {

0 commit comments

Comments
 (0)