为什么typeof(Inf)是双倍的?

问题描述 投票:0回答:1

在R,为什么typeof(Inf)返回double? R认为Infinity是实数还是只是数字?

x=1
xx=0
y=x/xx
typeof(y)

答案是"double"

谢谢

r double
1个回答
1
投票

一般来说,因为R中的任何数字文字都有double类型,除非它以L结尾:

> typeof(1)
double
> typeof(NA_real_)
double
> typeof(1L)
integer

更具体地说,因为Inf is a special value that can only be stored in a floating-point number,不是整数。

© www.soinside.com 2019 - 2024. All rights reserved.