archives

« Bugzilla Issues Index

#122 — Coverage: need a test for round-to-larger behavior in Number.prototype.toPrecision


https://bugzilla.mozilla.org/show_bug.cgi?id=669246

claims that (125).toPrecision(2) should equal 130. (I haven't quite verified this myself, but the quoted spec language seems on its face to suggest 130 is the desired behavior.) Not all the big JS engines do this. It'd be good to have a test to incent harmony here.

I would write a patch for this, but I don't believe Mozilla's legal people have worked through asinine ECMA-specific licensing issues yet. :-( Maybe someone else can? It should be utterly trivial.


From the same Mozilla bug, (123.445).toPrecision(5) should also be tested, with the result 123.44 (since 123.445 rounds to a double-precision number below 123.445) because MSIE appears to get this wrong. A user said that this is off-spec, but I disagree:

https://bugzilla.mozilla.org/show_bug.cgi?id=669246#c5

In case of disagreement, the ECMAScript spec should be clarified.