js中infinity_JavaScript中的Infinity属性

js中infinity

JavaScript | 无限属性 (JavaScript | Infinity Property)

The infinity property in JavaScript is much like the concept of infinity in mathematics where it is used to represent a number that is beyond our knowledge or one which cannot be expressed.

JavaScript中infinity属性与数学中的infinity概念非常相似,其中的infinity属性用于表示我们无法理解的数字或无法表达的数字。

console.log(Infinity);
console.log(-Infinity);

Output

输出量

Infinity
-Infinity

Logging both positive infinity and negative infinity on the console does not give us the values of the numbers which indicates that in JavaScript too, infinity holds a perception of a very large number.

在控制台上同时记录正无穷大和负无穷大并不能为我们提供数字的值,这也表明在JavaScript中,无穷大也可以感知非常大的数字。

You can easily deduce what large numbers are in a programming language. They are numbers that go out of range.

您可以轻松推断出编程语言中有多少。 它们是超出范围的数字。

console.log(3.4576917263943217389012348562315E+1203466)

Output

输出量

Infinity

This means that the number 3.4576917263943217389012348562315E+1203466 is considered an extremely large number and it indeed is since it falls out of the range of floating-point representation. As we know that JavaScript uses the floating-point representation to store numbers such large numbers are interpreted as Infinity.

这意味着数字3.4576917263943217389012348562315E + 1203466被认为是一个非常大的数字,并且确实是因为它不在浮点表示形式的范围内。 众所周知,JavaScript使用浮点表示法存储数字,如此大的数字被解释为Infinity。

console.log(-3.4576917263943217389012348562315E+1203)

Output

输出量

-Infinity

A number out of range of floating-point representation on the positive number line is interpreted as positive infinity and the number out of range of floating-point representation on the negative number line is interpreted as negative infinity.

正数行上超出浮点表示范围的数字将解释为正无穷大,负数行上超出浮点表示范围的数字将被解释为负无穷大。

console.log(999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);

Output

输出量

1e+219

The above number seems extremely large, doesn't it? However, if you look at 1e+219 and compare it with the infinity number 3.4576917263943217389012348562315E+1203 it seems extremely small! You can imagine how huge the limit of the floating-point representation is by comparing a huge number that you can imagine or think to the actual limit which is even beyond your imagination!

上述数字似乎很大,不是吗? 但是,如果您查看1e + 219并将其与无穷大数3.4576917263943217389012348562315E + 1203进行比较,则看起来非常小! 通过将您可以想象或想到的巨大数字与甚至超出您的想象力的实际极限进行比较,您可以想象到浮点表示的极限有多大!

翻译自: https://www.includehelp.com/code-snippets/infinity-property-in-javascript.aspx

js中infinity

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值