parseInt() parses number literals with exponent incorrectly

后端 未结 6 1467
慢半拍i
慢半拍i 2021-01-17 13:48

I have just observed that the parseInt function doesn\'t take care about the decimals in case of integers (numbers containing the e character).

6条回答
  •  深忆病人
    2021-01-17 14:16

    Math.round("12.2e-2") may round up or down based on the value. Hence may cause issues.

    new Number("3.2343e-10").toFixed(0) may solve the issue.

提交回复
热议问题