struct FP::FixedPoint(Underlying, Scale)
- FP::FixedPoint(Underlying, Scale)
- Number
- Value
- Object
Overview
Some helper conversions to fp32 & fp64
Defined in:
fixedpoint.crimpl.cr
Constructors
Class Method Summary
Instance Method Summary
- #%(other : self) : self
- #%(other : Number) : self
- #*(other : self) : self
- #*(other : Number) : self
- #**(other : self) : self
- #**(other : Number) : self
- #+(other : self) : self
- #+(other : Number) : self
- #-(other : self) : self
- #-(other : Number) : self
- #- : self
- #/(other : self) : self
- #/(other : Number) : self
-
#<=>(other : FixedPoint) : Int32
The comparison operator.
-
#<=>(other : Float) : Int32 | Nil
The comparison operator.
-
#<=>(other : Int) : Int32
The comparison operator.
- #ceil : self
- #floor : self
-
#hash(hasher)
Appends this object's value to hasher, and returns the modified hasher.
- #modulo(other) : self
- #remainder(other) : self
- #round_away : self
- #round_even : self
- #to_f : Float64
- #to_f32 : Float32
- #to_f64 : Float64
- #to_fp32 : FixedPoint32
- #to_fp64 : FixedPoint64
- #to_i : Int32
- #to_i32 : Int32
- #to_i64 : Int64
-
#to_s(io : IO) : Nil
Prints a nicely readable and concise string representation of this object, typically intended for users, to io.
- #trunc : self
Constructor Detail
Class Method Detail
Instance Method Detail
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 greater 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 greater 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 greater 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]
Appends this object's value to hasher, and returns the modified hasher.
Usually the macro def_hash
can be used to generate this method.
Otherwise, invoke #hash(hasher)
on each object's instance variables to
accumulate the result:
def hash(hasher)
hasher = @some_ivar.hash(hasher)
hasher = @some_other_ivar.hash(hasher)
hasher
end
Prints a nicely readable and concise string representation of this object, typically intended for users, to io.
This method is called when an object is interpolated in a string literal:
"foo #{bar} baz" # calls bar.to_io with the builder for this string
IO#<<
calls this method to append an object to itself:
io << bar # calls bar.to_s(io)
Thus implementations must not interpolate self
in a string literal or call
io << self
which both would lead to an endless loop.
Also see #inspect(IO)
.