JavaScript类型数组:64位整数? [英] JavaScript typed arrays: 64-bit integers?

查看:103
本文介绍了JavaScript类型数组:64位整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Firefox 4和Chrome 7中实现的JavaScript类型数组是在JavaScript中存储和处理二进制数据的一种非常有效的方式。但是,当前实现仅提供每个成员最多32位的整数视图,其中 Int32Array Uint32Array 。是否计划实施64位整数视图?如何实现64位整数视图?它们会慢多少?

JavaScript typed arrays, implemented in Firefox 4 and Chrome 7, are a very efficient way of storing and working with binary data in JavaScript. However, the current implementations only provide integer views up to 32 bits per member, with Int32Array and Uint32Array. Are 64-bit integer views being planned for implementation? How can I implement 64-bit integer views? How much slower will they be?

推荐答案

没有实用的方法来实现 Int64Array ,因为JavaScript中的所有数字都是64位浮点数字,只有53位精度。就像Simeon在他的评论中所说,你可以使用一个大的整数库,但它会慢得多。

There's no practical way to implement an Int64Array, because all numbers in JavaScript are 64-bit floating point numbers, which only have 53 bits of precision. Like Simeon said in his comment, you could use a big integer library, but it would be much slower.

如果你真的需要一个64位整数数组,无论如何性能方面,Google Closure库有一个 64位 Long我想象的比更通用的大整数库更快。我从来没有使用它,我不知道你是否可以轻松地将它与图书馆的其他部分分开。

If you really need an array of 64-bit integers, regardless of performance, the Google Closure library has a 64-bit Long class that I would imagine is faster than a more general big integer library. I've never used it though, and I don't know if you can separate it easily from the rest of the library.

这篇关于JavaScript类型数组:64位整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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