0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScriptの数字への変換 上限まとめ

Posted at

文字列を数値に変換するメソッド

数字が丸まる

18桁目で四捨五入処理が入る

// 21桁
const num = 123456789012345678901

console.log(Number(num)) //123456789012345680000
console.log(parseInt(num)) //123456789012345680000
console.log(parseFloat(num)) //123456789012345680000

表記が変更される

// 22桁
const num = 1234567890123456789012

console.log(Number(num)) //1.2345678901234568e+21
console.log(parseInt(num)) //1
console.log(parseFloat(num)) //1.2345678901234568e+21
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?