RESOLVED FIXED 7748
toPrecision sometimes messes up the last digit on intel Macs
https://bugs.webkit.org/show_bug.cgi?id=7748
Summary toPrecision sometimes messes up the last digit on intel Macs
Maciej Stachowiak
Reported 2006-03-12 19:21:01 PST
The JSC implementation of Number.toPrecision sometimes gets a different last digit on intel Macs than on PowerPC Macs or non-Mac intel systems. This is most likely due to a bug in the system pow() function. Nevertheless, I have a patch that works around it by directly coding computation of integer powers of 10.
Attachments
fix by adding intPow10 function (3.17 KB, patch)
2006-03-12 19:24 PST, Maciej Stachowiak
darin: review+
Maciej Stachowiak
Comment 1 2006-03-12 19:24:49 PST
Created attachment 7040 [details] fix by adding intPow10 function I only replaced toPrecision's use of pow(10.0, n) with intPow10(n). Should I do the same for toExponential and toFixed (even though we have not yet spotted a specific bug with those)? I am guessing they will face the same problem with pow()'s bad rounding of powers of 10.
Darin Adler
Comment 2 2006-03-12 20:44:17 PST
Comment on attachment 7040 [details] fix by adding intPow10 function - e = static_cast<int>(log10(x)); + e = static_cast<int>(trunc(log10(x))); Why that change? Does trunc add value? Why trunc and not floor? + n = floor(x / tens); Looks like there's a tab in the patch. r=me
Maciej Stachowiak
Comment 3 2006-04-04 02:00:52 PDT
Finally landed this.
Note You need to log in before you can comment on or make changes to this bug.