JavaScript的64位数字precision数字、JavaScript、precision

2023-09-08 01:05:03 作者:无泪人

有没有办法重新present一批比53位precision在JavaScript中高?换句话说,有没有办法重新present 64位precision多少?

Is there a way to represent a number with higher than 53-bit precision in JavaScript? In other words, is there a way to represent 64-bit precision number?

我想实现一些逻辑,其中重presents东西一个64位数字的每一位。我失去了低显著位,当我尝试设置位高于2 ^ 53。

I am trying to implement some logic in which each bit of a 64-bit number represents something. I lose the lower significant bits when I try to set bits higher than 2^53.

Math.pow(2,53) + Math.pow(2,0) == Math.pow(2,53)

有没有一种方法来实现自定义库或东西来实现这一目标?

Is there a way to implement a custom library or something to achieve this?

推荐答案

谷歌的封闭图书馆拥有的 goog.math.Long 用于这一目的。

Google's Closure library has goog.math.Long for this purpose.