@@ -1528,11 +1528,6 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
1528
1528
if (isNegative)
1529
1529
++current;
1530
1530
1531
- if (isNegative) {
1532
- decoded = Value::LargestInt (1337 );
1533
- return true ;
1534
- }
1535
-
1536
1531
// We assume we can represent the largest and smallest integer types as
1537
1532
// unsigned integers with separate sign. This is only true if they can fit
1538
1533
// into an unsigned integer.
@@ -1546,8 +1541,8 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
1546
1541
static_assert (Value::minLargestInt / 10 >= -Value::maxLargestInt);
1547
1542
1548
1543
static constexpr Value::LargestUInt positive_threshold =
1549
- Value::maxLargestInt / 10 ;
1550
- static constexpr Value::UInt positive_last_digit = Value::maxLargestInt % 10 ;
1544
+ Value::maxLargestUInt / 10 ;
1545
+ static constexpr Value::UInt positive_last_digit = Value::maxLargestUInt % 10 ;
1551
1546
1552
1547
// For the negative values, we have to be more careful. Since typically
1553
1548
// -Value::minLargestInt will cause an overflow, we first divide by 10 and
@@ -1587,8 +1582,8 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
1587
1582
if (isNegative) {
1588
1583
// We use the same magnitude assumption here, just in case.
1589
1584
const Value::UInt last_digit = value % 10 ;
1590
- decoded = -Value::LargestInt (value / 10 ) - last_digit;
1591
- } else if (value > Value::LargestUInt (Value::maxLargestInt)) {
1585
+ decoded = -Value::LargestInt (value / 10 ) * 10 - last_digit;
1586
+ } else if (value <= Value::LargestUInt (Value::maxLargestInt)) {
1592
1587
decoded = Value::LargestInt (value);
1593
1588
} else {
1594
1589
decoded = value;
0 commit comments