mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Minor logical fix.
This commit is contained in:
parent
26ecdea26c
commit
022118e5d0
@ -188,10 +188,8 @@ decimal parse_decimal(const char *p, const char *pend) noexcept {
|
||||
++p;
|
||||
}
|
||||
while ((p != pend) && is_integer(*p)) {
|
||||
if (answer.num_digits + 1 < max_digits) {
|
||||
if (answer.num_digits < max_digits) {
|
||||
answer.digits[answer.num_digits] = uint8_t(*p - '0');
|
||||
} else {
|
||||
answer.truncated = true;
|
||||
}
|
||||
answer.num_digits++;
|
||||
++p;
|
||||
@ -222,8 +220,6 @@ decimal parse_decimal(const char *p, const char *pend) noexcept {
|
||||
while ((p != pend) && is_integer(*p)) {
|
||||
if (answer.num_digits < max_digits) {
|
||||
answer.digits[answer.num_digits] = uint8_t(*p - '0');
|
||||
} else {
|
||||
answer.truncated = true;
|
||||
}
|
||||
answer.num_digits++;
|
||||
++p;
|
||||
@ -250,6 +246,10 @@ decimal parse_decimal(const char *p, const char *pend) noexcept {
|
||||
answer.decimal_point += (neg_exp ? -exp_number : exp_number);
|
||||
}
|
||||
answer.decimal_point += answer.num_digits;
|
||||
if(answer.num_digits > max_digits) {
|
||||
answer.truncated = true;
|
||||
answer.num_digits = max_digits;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
} // namespace fast_float
|
||||
|
||||
@ -150,6 +150,7 @@ int main() {
|
||||
|
||||
|
||||
std::cout << "======= 64 bits " << std::endl;
|
||||
Assert(basic_test_64bit("9355950000000000000.00000000000000000000000000000000001844674407370955161600000184467440737095516161844674407370955161407370955161618446744073709551616000184467440737095516166000001844674407370955161618446744073709551614073709551616184467440737095516160001844674407370955161601844674407370955674451616184467440737095516140737095516161844674407370955161600018446744073709551616018446744073709551611616000184467440737095001844674407370955161600184467440737095516160018446744073709551168164467440737095516160001844073709551616018446744073709551616184467440737095516160001844674407536910751601611616000184467440737095001844674407370955161600184467440737095516160018446744073709551616184467440737095516160001844955161618446744073709551616000184467440753691075160018446744073709",0x1.03ae05e8fca1cp+63));
|
||||
Assert(basic_test_64bit("-0",-0.0));
|
||||
Assert(basic_test_64bit("2.22507385850720212418870147920222032907240528279439037814303133837435107319244194686754406432563881851382188218502438069999947733013005649884107791928741341929297200970481951993067993290969042784064731682041565926728632933630474670123316852983422152744517260835859654566319282835244787787799894310779783833699159288594555213714181128458251145584319223079897504395086859412457230891738946169368372321191373658977977723286698840356390251044443035457396733706583981055420456693824658413747607155981176573877626747665912387199931904006317334709003012790188175203447190250028061277777916798391090578584006464715943810511489154282775041174682194133952466682503431306181587829379004205392375072083366693241580002758391118854188641513168478436313080237596295773983001708984375e-308", 0x1.0000000000002p-1022));
|
||||
Assert(basic_test_64bit("1.0000000000000006661338147750939242541790008544921875",1.0000000000000007));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user