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

Strange formatting behavior #784

Open
0xalecks opened this issue Apr 6, 2023 · 1 comment
Open

Strange formatting behavior #784

0xalecks opened this issue Apr 6, 2023 · 1 comment

Comments

@0xalecks
Copy link

0xalecks commented Apr 6, 2023

console.log(numeral('0.000000001').format('0.000000000')); // NaN
console.log(numeral('0.000000011').format('0.000000000')); // NaN
console.log(numeral('0.000000111').format('0.000000000')); // NaN
console.log(numeral('0.000001111').format('0.000000000')); // 0.000001111

console.log(numeral('0.00000001').format('0.00000000'));   // NaN
console.log(numeral('0.00000011').format('0.00000000'));   // NaN
console.log(numeral('0.00000111').format('0.00000000'));   // 0.00000111

console.log(numeral('0.0000001').format('0.0000000'));     // NaN
console.log(numeral('0.0000011').format('0.0000000'));     // 0.0000011
console.log(numeral('0.0000111').format('0.0000000'));     // 0.0000111

It seems any value less than 1e-6 is considered NaN, but higher values with more precision work?

@sunxi1997
Copy link

我也遇到了这个问题, 只有小数点后连续6位都是0时才会出现, 似乎是因为 js 会把这种数字强制使用科学计数法
image

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

No branches or pull requests

2 participants