mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
fix(dollar): $NaN -> "NaN", $Inf -> "Infinity" only when js (#24695)
ref nimpylib/pylib#44
---------
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
(cherry picked from commit 91e8e605d0)
This commit is contained in:
@@ -110,6 +110,10 @@ when defined(js):
|
||||
}
|
||||
if (Number.isSafeInteger(`a`))
|
||||
`result` = `a` === 0 && 1 / `a` < 0 ? "-0.0" : `a`+".0";
|
||||
else if (isNaN(`a`)) // Number.isNaN is since ES6
|
||||
`result` = "nan"; // or it'll be "NaN"
|
||||
else if (!isFinite(`a`)) // Number.isFinite newer but unnecessary here
|
||||
`result` = `a` > 0 ? "inf" : "-inf"; // or it'll be [-]Infinity
|
||||
else {
|
||||
`result` = `a`+"";
|
||||
if(nimOnlyDigitsOrMinus(`result`)){
|
||||
|
||||
Reference in New Issue
Block a user