marcandrysco / Errol

Binary floating-point to decimal string conversion algorithm.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errol4: Incorrect exponent for values close to a power of 10

tbkka opened this issue · comments

In testing a number of optimal formatting implementations for correctness, I've found the following serious error where Errol4 prints the wrong exponent:

Input: 0x1.6789e3750f79p-1017
Correct output: 9.999999999999999E-307
Errol4 prints: 9.999999999999999E-306

Note that the input here is the predecessor of a power of 10. This seems to be a pattern; Errol4 seems to have trouble with other numbers of this form.

Errol4 tests fail on this input, though slightly differently, in current code (commit 5364de4).

~/Repositories/Errol/test $ ./errol-test --fuzz4 1 --lower 0x1.6789e3750f79p-1017 --upper 0x1.6789e3750f79p-1017
Fuzzing Errol4... 0k/0k 0.00%Conversion failed. Expected 0.9999999999999999e-306. Actual 0.9999999999999999e-305. Read as 9.99999999999999870e-306.
Fuzzing Errol4 done on 1 numbers, 1 failures (100.000%), 1 suboptimal (100.000%), 1 notbest (100.000%)

Errol3 passes this example.