Float objects represent real numbers using the native architecture’s double-precision floating point representation.
ROUNDS | = | INT2FIX(FLT_ROUNDS) |
RADIX | = | INT2FIX(FLT_RADIX) |
MANT_DIG | = | INT2FIX(DBL_MANT_DIG) |
DIG | = | INT2FIX(DBL_DIG) |
MIN_EXP | = | INT2FIX(DBL_MIN_EXP) |
MAX_EXP | = | INT2FIX(DBL_MAX_EXP) |
MIN_10_EXP | = | INT2FIX(DBL_MIN_10_EXP) |
MAX_10_EXP | = | INT2FIX(DBL_MAX_10_EXP) |
MIN | = | rb_float_new(DBL_MIN) |
MAX | = | rb_float_new(DBL_MAX) |
EPSILON | = | rb_float_new(DBL_EPSILON) |
Return the modulo after division of flt by other.
6543.21.modulo(137) #=> 104.21 6543.21.modulo(137.24) #=> 92.9299999999996
Returns -1, 0, or +1 depending on whether flt is less than, equal to, or greater than numeric. This is the basis for the tests in Comparable.
Returns true only if obj has the same value as flt. Contrast this with Float#eql?, which requires obj to be a Float.
1.0 == 1 #=> true
Returns the smallest Integer greater than or equal to flt.
1.2.ceil #=> 2 2.0.ceil #=> 2 (-1.2).ceil #=> -1 (-2.0).ceil #=> -2
Returns the largest integer less than or equal to flt.
1.2.floor #=> 1 2.0.floor #=> 2 (-1.2).floor #=> -2 (-2.0).floor #=> -2
Returns nil, -1, or +1 depending on whether flt is finite, -infinity, or +infinity.
(0.0).infinite? #=> nil (-1.0/0.0).infinite? #=> -1 (+1.0/0.0).infinite? #=> 1
Return the modulo after division of flt by other.
6543.21.modulo(137) #=> 104.21 6543.21.modulo(137.24) #=> 92.9299999999996
Returns true if flt is an invalid IEEE floating point number.
a = -1.0 #=> -1.0 a.nan? #=> false a = 0.0/0.0 #=> NaN a.nan? #=> true
Rounds flt to the nearest integer. Equivalent to:
def round return floor(self+0.5) if self > 0.0 return ceil(self-0.5) if self < 0.0 return 0.0 end 1.5.round #=> 2 (-1.5).round #=> -2
Returns flt truncated to an Integer.
Returns flt truncated to an Integer.
Returns a string containing a representation of self. As well as a fixed or exponential form of the number, the call may return ``NaN’’, ``Infinity’’, and ``-Infinity’’.
Returns flt truncated to an Integer.