Float

The floating point value class. The implementation of Float is the same as in C.

Superclass

Methods

self + other
self - other
self * other
self / other
self % other
self ** other

Arithmetic operator. Computes the sum, difference, product, quotient, remainder, and exponent.

self <=> other

Compares other with self; returns a positive integer if self is larger, 0 if the two are equal, and a negative integer if self is smaller.

self == other
self < other
self <= other
self > other
self >= other

Relational operator.

finite?

Returns TRUE even if the value is infinite, unless it is also NaN.

infinite?

Returns 1 when a value is positive and infinite; returns -1 when a value is negative and infinite. Otherwise, returns nil. The floating point zero ensures infinite division.

inf = 1.0/0
p inf
p inf.infinite?

=> Infinity
   1

inf = -1.0/0
p inf
p inf.infinite?

=> -Infinity
   -1
nan?

Returns TRUE when a value is NaN (not a number). The floating point zero ensures the result of division by 0 is NaN.

nan = 0.0/0.0
p nan
p nan.nan?

=> NaN
   true
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)