mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 16:56:57 +08:00
Some optimization.
This commit is contained in:
parent
c53bfc4176
commit
8559cfa73f
@ -356,6 +356,9 @@ adjusted_mantissa parse_long_mantissa(const char *first, const char* last) {
|
|||||||
decimal d = parse_decimal(first, last);
|
decimal d = parse_decimal(first, last);
|
||||||
const uint64_t mantissa = d.to_truncated_mantissa();
|
const uint64_t mantissa = d.to_truncated_mantissa();
|
||||||
const int64_t exponent = d.to_truncated_exponent();
|
const int64_t exponent = d.to_truncated_exponent();
|
||||||
|
// credit: Nigel Tao who first implemented this fast path (to my knowledge).
|
||||||
|
// It is rough, but it does the job of accelerating the slow path since most
|
||||||
|
// long streams of digits are determined after 19 digits.
|
||||||
adjusted_mantissa am1 = compute_float<binary>(exponent, mantissa);
|
adjusted_mantissa am1 = compute_float<binary>(exponent, mantissa);
|
||||||
adjusted_mantissa am2 = compute_float<binary>(exponent, mantissa+1);
|
adjusted_mantissa am2 = compute_float<binary>(exponent, mantissa+1);
|
||||||
if( am1 == am2 ) { return am1; }
|
if( am1 == am2 ) { return am1; }
|
||||||
|
|||||||
@ -139,6 +139,7 @@ int main() {
|
|||||||
|
|
||||||
|
|
||||||
std::cout << "======= 64 bits " << std::endl;
|
std::cout << "======= 64 bits " << std::endl;
|
||||||
|
Assert(basic_test_64bit("2.22507385850720212418870147920222032907240528279439037814303133837435107319244194686754406432563881851382188218502438069999947733013005649884107791928741341929297200970481951993067993290969042784064731682041565926728632933630474670123316852983422152744517260835859654566319282835244787787799894310779783833699159288594555213714181128458251145584319223079897504395086859412457230891738946169368372321191373658977977723286698840356390251044443035457396733706583981055420456693824658413747607155981176573877626747665912387199931904006317334709003012790188175203447190250028061277777916798391090578584006464715943810511489154282775041174682194133952466682503431306181587829379004205392375072083366693241580002758391118854188641513168478436313080237596295773983001708984375e-308", 0x1.0000000000002p-1022));
|
||||||
Assert(basic_test_64bit("1.0000000000000006661338147750939242541790008544921875",1.0000000000000007));
|
Assert(basic_test_64bit("1.0000000000000006661338147750939242541790008544921875",1.0000000000000007));
|
||||||
Assert(basic_test_64bit("1090544144181609348835077142190",0x1.b8779f2474dfbp+99));
|
Assert(basic_test_64bit("1090544144181609348835077142190",0x1.b8779f2474dfbp+99));
|
||||||
Assert(basic_test_64bit("2.2250738585072013e-308",2.2250738585072013e-308));
|
Assert(basic_test_64bit("2.2250738585072013e-308",2.2250738585072013e-308));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user