Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Number.prototype.toFixed(n) #29

Closed
drsm opened this issue Jul 2, 2018 · 2 comments
Closed

add Number.prototype.toFixed(n) #29

drsm opened this issue Jul 2, 2018 · 2 comments
Assignees
Milestone

Comments

@drsm
Copy link
Contributor

drsm commented Jul 2, 2018

https://www.ecma-international.org/ecma-262/6.0/#sec-number.prototype.tofixed

@xeioex xeioex self-assigned this Aug 22, 2019
@xeioex xeioex added this to the 0.3.6 milestone Aug 30, 2019
@xeioex
Copy link
Contributor

xeioex commented Sep 2, 2019

@drsm

Take a look: https://gist.github.com/987c6eb18c7b9f45b305791e018f8116
Welcome to test.

@drsm
Copy link
Contributor Author

drsm commented Sep 2, 2019

@xeioex

Looks good!
Except the following:

>> (10**21).toFixed()
'1000000000000000000000' // bug 20.1.3.3 8. If x ≥ 10**21, then
>> (10**23).toFixed()
'9.999999999999999e+22' // not sure

vs

root@node:~# eshost -x "print((10**21).toFixed(2));"
#### ch
1e+21

#### jsc
1e+21

#### sm
1e+21

#### v8
1e+21

#### xs
1e+21

root@node:~# eshost -x "print((10**23).toFixed(2));"
#### ch
1e+23

#### jsc
1e+23

#### sm
1e+23

#### v8
1e+23

#### xs
9.999999999999999e+22

UPD:
1.

-    if (njs_slow_path(isnan(number) || fabs(number) > 1e21)) {
+    if (njs_slow_path(isnan(number) || fabs(number) >= 1e21)) {
  1. is related to Number.prototype.toString(), so OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants