Closed Bug 921908 Opened 13 years ago Closed 13 years ago

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

Categories

(Core :: JavaScript Engine, defect)

23 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 186563

People

(Reporter: richard, Unassigned)

Details

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
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
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.