Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
wrong output for 1000.fmt("%e") and 1_000_000.fmt("%e") #4892
$ perl6 --version
$ perl6 -e 'printf "%e\n", $_ for 1, 10, 100 ... 1_000_000;'
Outputs for 1_000 and 1_000_000 are not what they should.
I assume this is some kind of roundoff error when using floating point calculations to determine to go to the next power:
$ 6 'printf "%e\n",$_ for 11, 110, 1100 ... 1_100_000'
seems pretty ok, but then the value is not near the boundary.
This seems to be happening inside nqp::sprintf , and thus is really an NQP bug, or an underlying math lib bug.
This reminds me of a bug my navigator has: when the distance gets below 10 km, it will show one digit of accuracy (like in 9.9). However, the cutoff point is wrong, because if the value is still 9.95 km or above, it will round to 10, and thus show 10.0 for a little while. Not sure whether this anything to do with it.