Closed Bug 424473 Opened 18 years ago Closed 7 years ago

Erroneous loss of precision warning on (15).toFixed(-1) (debug only)

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
minor

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: x00000000, Unassigned)

References

()

Details

js> (15).toFixed(-1) WARNING: A loss of precision for double floating point is detected. The result of any operation on doubles can be meaningless. A possible cause is missing code to restore FPU state, see bug 360282 for details. 20 In js_dtoa(), where the warning would be canceled if d > 0.5 + eps, d is exactly 0.5 in this case, and control flows through the fast_failed label. Compare also bug 362641.
I haven't looked carefully, but is it a < vs <= issue? - if (1. - d < eps) { + if (1. - d <= eps) { /* Clear d to avoid precision warning. */ - if (d > 0.5 + eps) { + if (d >= 0.5 + eps) {
(In reply to comment #1) > I haven't looked carefully, but is it a < vs <= issue? No, eps is non-null and d is exactly 0.5, so that won't change anything. At the warning, d is 10.
This is still happening. Example: > (123123).toFixed(-3) 123000
This should throw a RangeError as per the spec: http://es5.github.com/x15.7.html#x15 I’m not sure what the “(debug only)” in the title is supposed to mean, but this still happens in the latest Firefox Nightly.
This bug had nothing to do with your error. And per spec we are allowed to have this behavior: >An implementation is permitted to extend the behaviour of toFixed for values of fractionDigits >less than 0 or greater than 20. In this case toFixed would not necessarily throw RangeError >for such values. But I agree, I don't see how values <0 are useful, Chrome also clips to 0 =< x =< 20.
Assignee: general → nobody
No longer reproducible because we're now always throwing a ReferenceError, therefore closing as INCOMPLETE.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.