如何在Node.js中进行64位整数运算? [英] How to do 64bit Integer arithmetic in Node.js?

查看:441
本文介绍了如何在Node.js中进行64位整数运算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都有关于如何在Node.js中对64位整数执行算术的任何建议? node-int64包似乎不支持它。

Anyone have any suggestions on how to perform arithmetic on 64bit integers in Node.js? The node-int64 package doesn't seem to support that.

推荐答案

Javascript不支持64位整数,因为本机数字类型是64位双精度,只有53位整数范围。

Javascript does not support 64 bit integers, because the native number type is a 64-bit double, giving only 53 bits of integer range.

您可以创建32位数字的数组(即 Uint32Array )但是如果有64位数字那些版本的那些无法将值复制到独立变量中。

You can create arrays of 32-bit numbers (i.e. Uint32Array) but if there were a 64-bit version of those there'd be no way to copy values from it into standalone variables.

有一些模块可以提供64位整数支持:

There are some modules around to provide 64bit integer support:

  • node-bigint
  • bignum (based on OpenSSL)
  • int64

也许您的问题可以使用其中一个库来解决。

Maybe your problem can be solved using one of those libraries.

这篇关于如何在Node.js中进行64位整数运算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆