本文简要介绍ruby语言中 Float.infinite?
的用法。
用法
infinite? → -1, 1, or nil
返回:
-
1,如果
self
是Infinity
。 -
-1 如果
self
是-Infinity
。 -
nil
,否则。
例子:
f = 1.0/0.0 # => Infinity
f.infinite? # => 1
f = -1.0/0.0 # => -Infinity
f.infinite? # => -1
f = 1.0 # => 1.0
f.infinite? # => nil
f = 0.0/0.0 # => NaN
f.infinite? # => nil
相关用法
- Ruby Float.self - other用法及代码示例
- Ruby Float.rationalize用法及代码示例
- Ruby Float.truncate用法及代码示例
- Ruby Float.quo用法及代码示例
- Ruby Float.finite?用法及代码示例
- Ruby Float.self / other用法及代码示例
- Ruby Float.coerce用法及代码示例
- Ruby Float.self < other用法及代码示例
- Ruby Float.numerator用法及代码示例
- Ruby Float.nan?用法及代码示例
- Ruby Float.to_int用法及代码示例
- Ruby Float.self % other用法及代码示例
- Ruby Float.self >用法及代码示例
- Ruby Float.fdiv用法及代码示例
- Ruby Float.next_float用法及代码示例
- Ruby Float.eql?用法及代码示例
- Ruby Float.to_d用法及代码示例
- Ruby Float.to_i用法及代码示例
- Ruby Float.self + other用法及代码示例
- Ruby Float.self >=用法及代码示例
- Ruby Float.self ** other用法及代码示例
- Ruby Float.modulo用法及代码示例
- Ruby Float.self ==用法及代码示例
- Ruby Float.self * other用法及代码示例
- Ruby Float.abs用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 Float.infinite?。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。