f number is say 1.1 then numbertoexponential(4) = 1.1000e+0 -- which is fine. number is 0.999 then numbertoexponential(4) = 9.9900e+1 -- which isn't. numbers less than 0.1 & greater than 0.9999 give expected results. tested on safari 2.0.4 & 3.1.1 & 4.beta
Created attachment 21943 [details] simple html/javascript showing the behaviour camino,firefox,opera give 'expected' result, webkit browsers don't.
Looks like fixes made for Acid3 in bug 16640 weren't sufficient.
The value of decimalAdjust in numberProtoFuncToExponential() is wrong when the value is between 0 and 1. Consider what happens with n = 0.1. If the number of digits is undefined, we get: decimalPoint = 0 decimalAdjust = 0 If the number of digits is defined, we get: decimalPoint = 1 decimalAdjust = -1
Created attachment 22049 [details] Proposed patch Actually, the problem isn't with decimalPoint and decimalAdjust, it's with what is done with the decimalPoint value in exponentialPartToString(). The sign check on the exponent is done on the decimalPoint value before subtracting 1 to get the exponent. Here is a patch that fixes it. I'll write some tests later and put it up for review, but I don't have the time before my calculus tutorial.
Comment on attachment 22049 [details] Proposed patch Makes sense, but needs the tests (hopefully in the fast/js .js file-only form. :)
Created attachment 22054 [details] Proposed patch with tests
Comment on attachment 22054 [details] Proposed patch with tests r=me
Landed in r34961.