WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
187650
Number.toPrecision returns a wrong value
https://bugs.webkit.org/show_bug.cgi?id=187650
Summary
Number.toPrecision returns a wrong value
isol2
Reported
2018-07-13 11:16:43 PDT
Version: JavaScriptCore v233804 OS: Ubuntu 16.04 x64 Hi everyone, I found an issue on a test case using Number.toPrecision that I don’t know if it is considered as an incompatibility issue between engines or a real bug example, but according with ES6 specs some values are described as "approximately" maybe this is a case of it. V8, JSC and SpiderMonkey returns the wrong value if param > 17, only Chakra works as expected. Steps to reproduce: print(123.56.toPrecision(18) === "123.560000000000000"); print(123.56.toPrecision(18)) Actual results: False 123.560000000000002 Expected results: True 123.560000000000000
Attachments
Add attachment
proposed patch, testcase, etc.
Alexey Shvayka
Comment 1
2021-05-06 17:46:26 PDT
(In reply to isol2 from
comment #0
)
> I found an issue on a test case using Number.toPrecision that I don’t know > if it is considered as an incompatibility issue between engines or a real > bug example, but according with ES6 specs some values are described as > "approximately" maybe this is a case of it.
Thank you for report! This is most certainly a IEEE 754 precision issue like 0.1 + 0.2 != 0.3. The spec prose is worded to highlight the inaccuracy: please see step 10.a of
https://tc39.es/ecma262/#sec-number.prototype.toprecision
.
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