A BigFloat
can represent arbitrarily large floats.
It is implemented under the hood with GMP.
The comparison operator.
The comparison operator.
Returns the absolute value of this number.
TODO improve this
Comparable(Float)
Comparable(BigFloat)
Comparable(Int)
Float
Float
Comparable(BigDecimal)
Comparable(BigRational)
Comparable(BigInt)
Number
Number
Number
Comparable(BigFloat)
Comparable(Number)
Value
Object
Object
The comparison operator. Returns 0
if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greter than other, or nil
if the two objects are not comparable.
Subclasses define this method to provide class-specific ordering.
The comparison operator is usually used to sort values:
# Sort in a descending way: [3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1] # Sort in an ascending way: [3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
The comparison operator. Returns 0
if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greter than other, or nil
if the two objects are not comparable.
Subclasses define this method to provide class-specific ordering.
The comparison operator is usually used to sort values:
# Sort in a descending way: [3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1] # Sort in an ascending way: [3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]
Returns the absolute value of this number.
123.abs # => 123 -123.abs # => 123
TODO improve this
© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/BigFloat.html