struct

FP::FixedPoint(Underlying, Scale)

Inherits Number < Steppable < Comparable < Value < Object

Some helper conversions to fp32 & fp64

Constructors

new(val : self)
Source
new(val : Number)
Source
zero
Source

Class methods

new_from_underlying(val : Underlying)
Source

Instance methods

%(other : self) : self
Source
%(other : Number) : self
Source
*(other : self) : self
Source
*(other : Number) : self
Source
**(other : self) : self
Source
**(other : Number) : self
Source
+(other : self) : self
Source
+(other : Number) : self
Source
-(other : self) : self
Source
-(other : Number) : self
Source
/(other : self) : self
Source
/(other : Number) : self
Source
<=>(other : FixedPoint) : Int32

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]
Source
<=>(other : Float) : Int32 | Nil

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]
Source
<=>(other : Int) : Int32

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]
Source
ceil
Source
floor
Source
hash(hasher)

See Object#hash(hasher)

Source
modulo(other) : self
Source
remainder(other) : self
Source
round_away
Source
round_even
Source
to_f
Source
to_f32
Source
to_f64
Source
to_fp32
Source
to_fp64
Source
to_i
Source
to_i32
Source
to_i64
Source
to_s(io : IO) : Nil

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).

Source
trunc
Source