File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -1360,11 +1360,23 @@ bool Value::isUInt64() const {
1360
1360
}
1361
1361
1362
1362
bool Value::isIntegral () const {
1363
+ switch (type_) {
1364
+ case intValue:
1365
+ case uintValue:
1366
+ return true ;
1367
+ case realValue:
1363
1368
#if defined(JSON_HAS_INT64)
1364
- return isInt64 () || isUInt64 ();
1369
+ // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
1370
+ // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
1371
+ // require the value to be strictly less than the limit.
1372
+ return value_.real_ >= double (minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral (value_.real_ );
1365
1373
#else
1366
- return isInt () || isUInt ();
1367
- #endif
1374
+ return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral (value_.real_ );
1375
+ #endif // JSON_HAS_INT64
1376
+ default :
1377
+ break ;
1378
+ }
1379
+ return false ;
1368
1380
}
1369
1381
1370
1382
bool Value::isDouble () const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
You can’t perform that action at this time.
0 commit comments