Fixed a bug in trimming long number sequence
This commit is contained in:
parent
4cc62876ae
commit
4824f12efb
|
@ -258,7 +258,9 @@ inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t
|
|||
// Trim right-most digits
|
||||
const int kMaxDecimalDigit = 780;
|
||||
if ((int)length > kMaxDecimalDigit) {
|
||||
exp += (int(length) - kMaxDecimalDigit);
|
||||
int delta = (int(length) - kMaxDecimalDigit);
|
||||
exp += delta;
|
||||
decimalPosition -= delta;
|
||||
length = kMaxDecimalDigit;
|
||||
}
|
||||
|
||||
|
|
|
@ -289,6 +289,19 @@ static void TestParseDouble() {
|
|||
TEST_DOUBLE(fullPrecision, n1e308, 1E308);
|
||||
}
|
||||
|
||||
// Cover trimming
|
||||
TEST_DOUBLE(fullPrecision,
|
||||
"2.22507385850720113605740979670913197593481954635164564802342610972482222202107694551652952390813508"
|
||||
"7914149158913039621106870086438694594645527657207407820621743379988141063267329253552286881372149012"
|
||||
"9811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306"
|
||||
"6665599493827577257201576306269066333264756530000924588831643303777979186961204949739037782970490505"
|
||||
"1080609940730262937128958950003583799967207254304360284078895771796150945516748243471030702609144621"
|
||||
"5722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844"
|
||||
"2390026549819838548794829220689472168983109969836584681402285424333066033985088644580400103493397042"
|
||||
"7567186443383770486037861622771738545623065874679014086723327636718751234567890123456789012345678901"
|
||||
"e-308",
|
||||
2.2250738585072014e-308);
|
||||
|
||||
#if 0 // Very slow
|
||||
static const unsigned count = 10000000;
|
||||
// Random test for double
|
||||
|
|
Loading…
Reference in New Issue