tofixed(2) incorrectly rounding 3 decimal places number with 3rd digit 5

RESOLVED DUPLICATE of bug 186563

Status

()

Core
JavaScript Engine
RESOLVED DUPLICATE of bug 186563
5 years ago
5 years ago

People

(Reporter: Richard, Unassigned)

Tracking

23 Branch
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

5 years ago
User Agent: Mozilla/5.0 (Windows NT 5.1; rv:23.0) Gecko/20100101 Firefox/23.0 (Beta/Release)
Build ID: 20130814063812

Steps to reproduce:

Rounding a number with toFixed(2) on a number with 3 decimal places with the third decimal being 5 incorrectly rounds down.
In javascript or with scratchpad
alert((1000.035).toFixed(2)) should show 1000.04 - as 
alert((1000.0035).toFixed(3)) returns 1000.004 and 
alert((1000.35).toFixed(1)) returns 1000.4

alert((1000.036).toFixed(2)) DOES return 1000.04


Actual results:

The result is 1000.03


Expected results:

1000.04

Comment 1

5 years ago
Google Chrome produces the same result (1000.03). See also http://stackoverflow.com/questions/10015027/javascript-tofixed-not-rounding

So I'm not sure if it's technically a bug or not.
Component: Untriaged → JavaScript Engine
Product: Firefox → Core

Updated

5 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 186563
You need to log in before you can comment on or make changes to this bug.