1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:07:44 +00:00

LibJS: Implement Number.prototype.toPrecision

As noted in the prototype comments, this implementation becomes less
accurate as the precision approaches the limit of 100. For example:

    (3).toPrecision(100)

Should result in "3." followed by 99 "0"s. However, due to the loss of
accuracy in the floating point computations, we currently result in
"2.9999999...".
This commit is contained in:
Timothy Flynn 2022-01-02 23:06:51 -05:00 committed by Linus Groh
parent f1eb975a7a
commit dc984c53d8
5 changed files with 260 additions and 0 deletions

View file

@ -468,6 +468,7 @@ namespace JS {
P(toPlainMonthDay) \
P(toPlainTime) \
P(toPlainYearMonth) \
P(toPrecision) \
P(toString) \
P(total) \
P(toTemporalInstant) \