WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 24711
31777
Number.toFixed returns wrong values
https://bugs.webkit.org/show_bug.cgi?id=31777
Summary
Number.toFixed returns wrong values
bugzilla33
Reported
2009-11-21 16:50:01 PST
Created
attachment 43667
[details]
source Number.toFixed returns sometimes wrong values (incorect rounding). Please run attachment. Actual Results: ( 0.95 ) . toFixed ( 1 ) = 0.9 THOUGH ( 9.5 ) . toFixed ( 0 ) = 10 Expected Results: ( 0.95 ) . toFixed ( 1 ) = 1.0 LIKE ( 9.5 ) . toFixed ( 0 ) = 10
Attachments
source
(1.48 KB, text/html)
2009-11-21 16:50 PST
,
bugzilla33
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2009-11-21 22:55:08 PST
Duplicate of
bug 24711
?
bugzilla33
Comment 2
2009-11-22 01:06:09 PST
toFixed rounds, not floors !
bug 24711
is not a Bug !! (1.95) . toFixed( 1 ) = 2.0 because: Math.round ( 1.95 * 10 ) / 10 equal 2
bugzilla33
Comment 3
2009-11-22 01:14:34 PST
All browsers before returns string value (IE, Opera, Konqueror, Chrome, Firefox) rounding a Number.
Gavin Barraclough
Comment 4
2010-08-27 12:56:54 PDT
yep, this is a dupe. ieee754(.95) < decimal(.95), hence rounds up to 0.9 (ecma-262 15.7.4.5 requires we select the nearest value). ieee754(9.5) == decimal(9.5), hence rounds up to 10 (ecma-262 15.7.4.5 requires we select the larger to two equally near values). *** This bug has been marked as a duplicate of
bug 24711
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug