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?

JavaScript: お手軽にbigint型をnumber型に変換

0
Last updated at Posted at 2026-11-12

Number(BigInt(n))などと書く以外にも手短にするなら配列に格納する手がある。そこから数値変換

let n=9876543210n, a=+[n], b=[n]|0, c=+[n]+ +[n]-1e8+a;

ただしNumber(BigInt(n))より遥かに低速である。ちなみに演算子による評価結果の違いに注意

[1n]+[1n] //string
+[1n]+[1n] //string
[1n]-[1n] //number
[1n]/[1n] //number
[1n]*[1n] //number
0
0
0

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?