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

The decimal format (d) isn’t observed if x ≥ 1e21. #24

Closed
mbostock opened this issue Jun 28, 2016 · 2 comments
Closed

The decimal format (d) isn’t observed if x ≥ 1e21. #24

mbostock opened this issue Jun 28, 2016 · 2 comments

Comments

@mbostock
Copy link
Member

For example:

var f = d3.format(",d");
f(1e20); // "100,000,000,000,000,000,000"
f(1e21); // "1e+21"

Because:

(1e20).toString(10); // "100000000000000000000"
(1e21).toString(10); // "1e+21"

Related #21.

@mbostock
Copy link
Member Author

mbostock commented Sep 5, 2019

On the other hand, toLocaleString seems to do what we want:

(1e21).toLocaleString("en") // "1,000,000,000,000,000,000,000"

@mbostock
Copy link
Member Author

Fixed in #104.

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