crow/number.crow (source)

Other functions are in 'math.crow'

int alias

nat alias

float alias

integral-value union

Used to store values for exceptions

to integral-value(a nat8) bare

to integral-value(a nat16) bare

to integral-value(a nat32) bare

to integral-value(a nat64) bare

to integral-value(a int8) bare

to integral-value(a int16) bare

to integral-value(a int32) bare

to integral-value(a int64) bare

unary-out-of-range record exception variant-member

show string(anonymous unary-out-of-range)

binary-out-of-range record exception variant-member

show string(anonymous binary-out-of-range)

divide-by-0 record exception variant-member

    show string(anonymous divide-by-0)

    + nat8(a nat8, b nat8) bare

    Throws if the result would overflow.

    "Overflow" means: be greater than the maximum possible value.

    + nat16(a nat16, b nat16) bare

    + nat32(a nat32, b nat32) bare

    + nat64(a nat64, b nat64) bare

    - nat8(a nat8, b nat8) bare

    Throws if the result would be negative.

    - nat16(a nat16, b nat16) bare

    - nat32(a nat32, b nat32) bare

    - nat64(a nat64, b nat64) bare

    * nat64(a nat64, b nat64) bare

    Throws if the result would overflow.

    / nat64(a nat64, b nat64) bare

    Flooring division of a divided by b.
    Throws if b == 0.

    div-ceil nat64(a nat64, b nat64) bare

    Like 'a / b' but takes the ceil instead of the floor.

    % nat64(a nat64, b nat64) bare

    Remainder of a / b.
    Result will be in the range 0 .. b.
    Throws if b == 0.

    % nat32(a nat32, b nat32) bare

    % nat64(a int64, b nat64) bare

    This returns a nat64 since modulo always returns a non-negative number.

    is-multiple-of bool(a nat64, b nat64) bare

    true iff b * x == a for some x.

    round-down-to-multiple-of nat64(a nat64, b nat64) bare

    + int8(a int8, b int8) bare

    Throws if the result would overflow.

    "Overflow" means:
    Be less than the least possible value or greater than the greatest possible value.

    + int16(a int16, b int16) bare

    + int32(a int32, b int32) bare

    + int64(a int64, b int64) bare

    - int32(a int32, b int32) bare

    - int64(a int64, b int64) bare

    * int8(a int8, b int8) bare

    * int16(a int16, b int16) bare

    * int32(a int32, b int32) bare

    * int64(a int64, b int64) bare

    - int8(a int8) bare

    Negates a number.
    Same as a * -1.

    Throws if a is the least possible value.

    - int16(a int16) bare

    - int32(a int32) bare

    - int64(a int64) bare

    / int32(a int32, b int32) bare

    Flooring division.
    Throws if b == 0.
    Throws if the result would overflow, which only happens if
    a is the least possible value and b is -1.

    / int64(a int64, b int64) bare

    abs nat64(a int64) bare

    Absolute value.
    For an integer type, throws for min-value.

    abs float32(a float32) bare

    abs float64(a float64) bare

    ** nat64(a nat64, b nat64) bare

    + float32(a float32, b float32) bare

    Never throws.

    + float64(a float64, b float64) bare

    - float32(a float32) bare

    Never throws.

    - float64(a float64) bare

    - float32(a float32, b float32) bare

    Never throws.

    - float64(a float64, b float64) bare

    * float32(a float32, b float32) bare

    Never throws.

    * float64(a float64, b float64) bare

    / float32(a float32, b float32) bare

    Throws if b == 0.

    / float64(a float64, b float64) bare

    ** float32(a float32, b int64) bare

    a to the power of b. Never throws.

    ** float64(a float64, b int64) bare

    nan float32() unsafe

    Not-a-Number value.
    'unsafe' because Crow generally throws exceptions instead of returning NaN.

    nan float64() unsafe

    infinity float32()

    infinity float64()

    is-nan bool(a float32)

    true iff a is "Not A Number".

    is-nan bool(a float64)

    is-near-int bool(a float64)

    is-near bool(a float64, b float64)

    epsilon float64()

    to float32(a nat64) bare

    Conversions between integral types throw on overflow or underflow.
    Conversions involving floats (in either direction) are approximate and never throw.

    to float32(a int64) bare

    to float32(a float64) bare

    to float64(a nat64) bare

    to float64(a int64) bare

    to float64(a float32) bare

    to int64(a float64) bare

    round float32(a float32) bare

    round float64(a float64) bare

    round-down float32(a float32) bare

    floor

    round-down float64(a float64) bare

    round-up float32(a float32) bare

    ceiling

    round-up float64(a float64) bare

    to nat64(a float64) bare

    to nat32(a float64) bare

    to int64(a nat64) bare

    Throws if the result would overflow.

    to int8(a int64) bare

    to int16(a int64) bare

    to int32(a int64) bare

    Convert an int to 32 bits. Fail if the result would overflow.

    to int32(a nat32) bare

    to int32(a nat16) bare

    to int32(a nat64) bare

    clamp-sub nat64(a nat64, b nat64)

    clamp-to int32(a int64) bare

    Return the closest value. Never throws.

    clamp-to int32(a nat64) bare

    clamp-to int64(a nat64) bare

    clamp-to nat8(a nat64) bare

    clamp-to nat64(a int64) bare

    clamp-to nat64(a float64) bare

    clamp-add int32(a int32, b int32) bare

    Return the closest possible value to a + b. Never throws.

    to nat64(a int64) bare

    Throws if the result would not have the same value as the input (due to overflow or underflow)

    to nat64(a int32) bare

    to nat8(a nat32) bare

    to nat8(a nat64) bare

    to nat8(a float64) bare

    to nat32(a nat8) bare

    to nat32(a nat16) bare

    to nat32(a nat64) bare

    truncate-to int64(a float64) bare

    nat8 builtin

    8-bit natural number.
    An unsigned integer in the range 0 through 255.

    nat16 builtin

    16-bit natural number.
    An unsigned integer in the range 0 through 65_535.

    nat32 builtin

    32-bit natural number.
    An unsigned integer in the range 0 through 4_294_967_295 (4 billion).

    nat64 builtin

    64-bit natural number.
    An unsigned integer in the range 0 through 18_446_744_073_709_551_615 (18 quintillion).

    int8 builtin

    8-bit signed integer.
    In the range -128 through 127.

    int16 builtin

    16-bit signed integer.
    In the range -32_768 through 32_767.

    int32 builtin

    32-bit signed integer.
    In the range -2_147_483_648 through 2_147_483_647 (-2 billion through 2 billion).

    int64 builtin

    64-bit signed integer,
    In the range 9_223_372_036_854_775_808 through 9_223_372_036_854_775_807
    (-9 quintillion through 9 quintillion).

    float32 builtin

    32-bit IEEE floating point number.

    float64 builtin

    64-bit IEEE floating point number.

    new nat8() bare

    Same as 0.

    new nat16() bare

    new nat32() bare

    new nat64() bare

    new int8() bare

    new int16() bare

    new int32() bare

    new int64() bare

    new float32() bare

    new float64() bare

    <=> comparison(a nat8, b nat8) bare

    <=> comparison(a nat16, b nat16) bare

    <=> comparison(a nat32, b nat32) bare

    <=> comparison(a nat64, b nat64) bare

    <=> comparison(a int8, b int8) bare

    <=> comparison(a int16, b int16) bare

    <=> comparison(a int32, b int32) bare

    <=> comparison(a int64, b int64) bare

    <=> comparison(a float64, b float64) bare

    <=> comparison(a float32, b float32) bare

    == bool(a nat8, b nat8) bare

    == bool(a nat16, b nat16) bare

    == bool(a nat32, b nat32) bare

    == bool(a nat64, b nat64) bare

    == bool(a int8, b int8) bare

    == bool(a int16, b int16) bare

    == bool(a int32, b int32) bare

    == bool(a int64, b int64) bare

    == bool(a float32, b float32) bare

    == bool(a float64, b float64) bare

    wrap-to nat32(a nat64) bare

    wrap-to int32(a nat32) bare

    wrap-to nat32(a int32) bare

    to nat16(a nat8) bare

    to nat64(a nat8) bare

    to nat64(a nat16) bare

    to nat64(a nat32) bare

    to int64(a int8) bare

    to int64(a int16) bare

    to int64(a int32) bare

    is-even bool(a nat64) bare

    Equivlaent to a is-multiple-of 2.

    min-value int8() bare

    Least possible value for a type.

    min-value int16() bare

    min-value int32() bare

    min-value int64() bare

    max-value int8() bare

    Greatest possible value for a type.

    max-value int16() bare

    max-value int32() bare

    max-value int64() bare

    max-value nat8() bare

    max-value nat16() bare

    max-value nat32() bare

    max-value nat64() bare