JavaScript Integer math incorrect results

前端 未结 4 475
眼角桃花
眼角桃花 2020-12-09 07:17

I am just trying to implement a simple RNG in JS.

What\'s happening is javascript evaluates 119106029 * 1103515245 to be 131435318772912110

4条回答
  •  有刺的猬
    2020-12-09 07:31

    With the arrival of BigInt, you can now perform these calculations with accuracy:

    console.log((119106029n * 1103515245n).toString());

提交回复
热议问题