javascript中如何处理大数字

发布于 2024-10-04 06:02:46 字数 161 浏览 1 评论 0原文

我正在寻找一个处理真正(长、大、巨大、风暴)数字的数学解决方案。我还没有发现任何东西,但我不想认为这个问题目前还没有解决。我正在寻找一个简单的数字解决方案,例如 Microsoft Excel Precision(30 位小数)或 BigInteger (Java) 解决方案。当然是用Javascript。

I'm looking for a Mathematical solution that deals with really (long, big, huge, storms) numbers. I haven't found anything yet, But I don't wanna think that this problem hasn't be solve at this time. I'm looking for an easy Number solution, like Microsoft Excel Precision (30 decimals), or a BigInteger (Java) solution. in Javascript of course.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蹲在坟头点根烟 2024-10-11 06:02:46

在为 ElGamal 加密实现寻找大整数库时,我测试了几个库,结果如下:

我推荐这个: Tom Wu 的 jsbn.js (http://www-cs-students.stanford.edu/~tjw/jsbn/)

  • 全面的函数集和快速

Leemon Baird 的大整数库 (http://www.leemon .com/crypto/BigInt.js)

  • 功能齐全且速度相当快
  • 但是:负数表示有问题!

bignumber.js (https://github.com/MikeMcl/bignumber.js)

  • 相当完整的函数集
  • 但是: 将非常大的数字从字符串转换为 BigNumber 对象会产生 INFINITY

JavaScript 的 Schema 算术库 (https://github.com/jtobey/javascript-bignum)

  • JS-Scheme 算术函数的实现
  • 但是: y= x^e mod n 没有函数

我自己还没有测试过这个: BigNumber (http://jsfromhell.com/classes/bignumber)

  • 用于高精度计算的函数
  • 但是:由于内部表示,据说速度很慢作为字符串的数字

While looking for an big integer library for an ElGamal crypto implementation I tested several libraries with the following results:

I recommend this one: Tom Wu's jsbn.js (http://www-cs-students.stanford.edu/~tjw/jsbn/)

  • Comprehensive set of functions and fast

Leemon Baird's big integer library (http://www.leemon.com/crypto/BigInt.js)

  • Comprehensive set of functions and pretty fast
  • BUT: Negative number representation is buggy!

bignumber.js (https://github.com/MikeMcl/bignumber.js)

  • Pretty complete set of functions
  • BUT: Converting really big numbers from strings into BigNumber objects result in INFINITY

Scheme arithmetic library for JavaScript (https://github.com/jtobey/javascript-bignum)

  • JS-Implementation of Scheme arithmetic functions
  • BUT: No function for y= x^e mod n

I haven't tested this by myself: BigNumber (http://jsfromhell.com/classes/bignumber)

  • Functions for high precision claculations
  • BUT: It's said to be slow due to internal representation of numbers as strings
情泪▽动烟 2024-10-11 06:02:46

这里有一个 JavaScript 的 BigInteger 库:

(请注意我自己没用过这个,试试看你的想法。)

There's a BigInteger library for JavaScript available here:

(Note that I haven't used this myself. Try it and see what you think.)

木落 2024-10-11 06:02:46

还有 Silent Matt 的大整数。它不处理小数。

There is also Silent Matt's library for Big Integers. It does not handle decimals.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文