Float64
In the prelude: every iyi program has it, with no import.
Float64struct
struct Float64 < Float
def !=(other : Int32) : Bool
def !=(other : Int64) : Bool
def !=(other : UInt8) : Bool
def !=(other : UInt64) : Bool
def !=(other : Float64) : Bool
def *(other : Int32) : self
def *(other : Int64) : self
def *(other : UInt8) : self
def *(other : UInt64) : self
def *(other : Float64) : self
# A whole power by squaring in double-double - the power and the base each
# a sum of two doubles good to some 106 bits - rounded once, at the end.
# In plain doubles every step rounded: `1.1 ** 100` was 13780.612339822364
# and `0.9999999 ** 10000000` 854,604 ulp off. A negative exponent powers
# the reciprocal, itself a pair, so `2.0 ** -1074` is 5.0e-324 although
# `2.0 ** 1074` is infinite, and `Int32::MIN` is counted in an Int64.
def **(exponent : Int32) : Float64
def +(other : Int32) : self
def +(other : Int64) : self
def +(other : UInt8) : self
def +(other : UInt64) : self
def +(other : Float64) : self
def -(other : Int32) : self
def -(other : Int64) : self
def -(other : UInt8) : self
def -(other : UInt64) : self
def -(other : Float64) : self
def /(other : Float64) : Float64
def <(other : Int32) : Bool
def <(other : Int64) : Bool
def <(other : UInt8) : Bool
def <(other : UInt64) : Bool
def <(other : Float64) : Bool
def <=(other : Int32) : Bool
def <=(other : Int64) : Bool
def <=(other : UInt8) : Bool
def <=(other : UInt64) : Bool
def <=(other : Float64) : Bool
def ==(other : Int32) : Bool
def ==(other : Int64) : Bool
def ==(other : UInt8) : Bool
def ==(other : UInt64) : Bool
def ==(other : Float64) : Bool
def >(other : Int32) : Bool
def >(other : Int64) : Bool
def >(other : UInt8) : Bool
def >(other : UInt64) : Bool
def >(other : Float64) : Bool
def >=(other : Int32) : Bool
def >=(other : Int64) : Bool
def >=(other : UInt8) : Bool
def >=(other : UInt64) : Bool
def >=(other : Float64) : Bool
# The sign cleared, which a comparison cannot do: `-0.0 < 0.0` is false,
# and `(-0.0).abs` answered `-0.0` - `log10(-0.0)` came out `+Infinity`
# for it. `copysign` is an instruction on every target.
def abs : Float64
def ceil : Float64
def fdiv(other : Int32) : self
def fdiv(other : Int64) : self
def fdiv(other : UInt8) : self
def fdiv(other : UInt64) : self
def fdiv(other : Float64) : self
# The integer below and above, as a `Float64`: one instruction where the
# processor has it (`IyiRounding`), the conversion below where it does
# not. Past 2^52 every double is an integer already and is answered as
# it is, as NaN and the infinities are; the conversion is exact under
# it. The answer carries the argument's sign, which is where a zero's
# comes from - `(-0.3).ceil` is `-0.0`, as the instruction and the other
# library answer.
def floor : Float64
# `-0.0 == 0.0`, so they hash alike. It was `std/float`'s, and a
# `Hash(Float64, V)` without that import put every key in one slot.
def hash : Int32
# To `digits` places, a tie to the even one: scaled, rounded, scaled
# back, so `3.14159.round(2)` is the double nearest 3.14. A negative
# `digits` rounds to tens, hundreds, ...: `1234.0.round(-2)` is 1200.0,
# and `25.0.round(-1)` is 20.0. The scale for those divides first rather
# than multiplying by a fraction, which no double spells exactly.
#
# Where the scale leaves a double's range the answer is at hand, and the
# arithmetic made Infinity or NaN of it: a double at 2^52 or past has no
# fraction to round (`1e308.round(1)` was Infinity), a scale past the
# range keeps every digit a double has (`1.5.round(400)` was NaN), and
# one past the range the other way is a zero (`1.5.round(-400)`).
#
# A scaled value at 2^53 or past is at hand the same way: the place
# `digits` names is finer than the double's last bit, so the nearest
# double to the rounded decimal is the double itself. Scaled back, it
# moved: `0.8173247445520655.round(17)` was 0.8173247445520654, and
# `(-0.05).round(300)`, whose scale `10.0 ** 300` is not 10^300 exactly,
# was -0.049999999999999996. Between 2^52 and 2^53 the place can still
# be the coarser one, so that band is scaled back as before.
def round(digits : Int32) : Float64
# The nearest integer, a tie to the even one — Crystal's `round`, so the
# name means one thing in both libraries (SPEC.md III.1.7a): `2.5.round`
# is 2.0 and `3.5.round` is 4.0. `std/number` names the other modes.
# The magnitude's fraction decides, not a sum: `(x + 0.5).floor` rounded
# the sum first, and 0.49999999999999994 + 0.5 is 1.0. The sign goes
# back by a multiplication, so `(-0.25).round` is -0.0, as there. A zero
# is its own nearest integer and is answered as it is: `-0.0 < 0.0` is
# false, and the sign test below answered `(-0.0).round` as 0.0.
def round : Float64
def to_f : Float64
def to_f64 : Float64
# The checked form raises on overflow — which in this prelude is a panic,
# since `__crystal_raise_overflow` prints and exits (SPEC.md III.1.4).
#
# The unchecked form is the conversion without the check, and a float
# past the range saturates (NaN is 0), alike in every build. It is
# spelled the way `unsafe_chr` below is: `unsafe_to_u8`. Crystal spells
# it `to_u8!`, which is not a name in iyi (SPEC.md III.1.7) — those
# declarations were accepted only because a macro expansion was
# reparsed by the other language's rules, and no iyi source could call
# one: `x.to_u8!` is `x.to_u8` with its error propagated. The callers
# wanted the instruction: `memset`'s `value.to_u8!` is C's "converted to
# unsigned char", and the checked form panics on 0x1ff where C writes 0xff.
def to_i : Int32
def to_i32 : Int32
def to_i64 : Int64
def to_s : String
def to_u64 : UInt64
def to_u8 : UInt8
def unsafe_to_f : Float64
def unsafe_to_f64 : Float64
def unsafe_to_i : Int32
def unsafe_to_i32 : Int32
def unsafe_to_i64 : Int64
def unsafe_to_u64 : UInt64
def unsafe_to_u8 : UInt8
def self.zero : self
end