在 Javascript 中始终将数字作为 64 个浮点数到底意味着什么?

What exactly does it mean in Javascript to always have numbers as 64 floating points?

我目前正在研究对象和原始数据类型的一般差异,并在 W3schools 上看到了这篇文章。

直接引用自w3schools.com:

JavaScript Numbers are Always 64-bit Floating Point

Unlike many other programming languages, JavaScript does not define different types of numbers, like integers, short, long, floating-point etc.

JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard.

This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63

简单来说,有人可以给我举个例子吗? 具体来说,与其他语言(如 C++ 或 Java)相比,这在整个编程中究竟意味着什么。

按 F12 在浏览器中启动开发人员工具,然后转到控制台并执行以下命令:

typeof 1234
typeof 2e32
typeof 12.34
typeof 12.34e56

在所有情况下你都会得到 "number"。无论您的值是整数(小或大)还是小数(同样,小或大到需要科学记数法),该语言只公开一种类型来表示所有这些。

将此与 the numeric types exposed by by .NET (source) 进行比较,您会发现有多种类型可供选择,具体取决于您使用的数字的大小和类型。

这是否意味着 JavaScript 在某些方面比 .NET(或 Java 或提供类似类型的任何其他语言)更好或更差?不必要。它们是用于不同目的的不同语言,并且以不同方式平衡复杂性和功能。