Skip to content
FutureBlitz

    Install

    Import std.math.fixed

    Fixed32

    std.math.fixed

    struct

    Public Struct Fixed32 Implements Numeric, Comparable, Hashable, Bounded, Printable, Defaultable

    A number with 16 bits for its whole part, its sign among them, and 16 after the point: from -32768 to 32767.99998, in steps of 1 / 65536.

    Examples

    Local three = Fixed32.FromInt(3)
    Local four = Fixed32.FromInt(4)
    Expect((three / four).ToDouble() == 0.75)
    Expect(three * four == Fixed32.FromInt(12))
    Expect(Fixed32.FromDouble(1.5).Raw == 98304)
    Expect(Sqrt(Fixed32.FromInt(16)) == four)

    std/math/fixed.fb, line 317

    • Public Static Method FromRaw(bits: Int32): Fixed32 static method #

      The Fixed32 these bits are, as Raw gives them.

    • @PanicsAtCaller Public Static Method FromInt(value: Int): Fixed32 static method #

      The whole number. One outside -32768 to 32767 panics.

    • @PanicsAtCaller Public Static Method FromDouble(value: Double): Fixed32 static method #

      The Double, rounded to the nearest Fixed32, halves away from 0. One outside a Fixed32's range, or NaN, panics.

    • @PanicsAtCaller Public Static Method FromFloat(value: Float): Fixed32 static method #

      The Float, rounded to the nearest Fixed32, halves away from 0. One outside a Fixed32's range, or NaN, panics.

    • Public Static Method Zero(): Fixed32 static method #

      The zero Fixed32, which adding leaves alone.

    • Public Static Method One(): Fixed32 static method #

      The Fixed32 1, raw 65536, which multiplying leaves alone.

    • Public Static Method DefaultValue(): Fixed32 static method #

      The zero Fixed32.

    • Public Static Method MinValue(): Fixed32 static method #

      The lowest Fixed32, -32768.

    • Public Static Method MaxValue(): Fixed32 static method #

      The highest Fixed32, about 32767.99998.

    • Public Static Method DoubleValue(value: Fixed32): Double static method #

      The value as a Double, which holds every one exactly.

    • Public Static Property Pi: Fixed32 property #

      Pi, and a turn, 2 Pi, rounded to a Fixed32's steps.

    • Public Static Property Tau: Fixed32 property #

      A turn, 2 Pi, rounded to a Fixed32's steps.

    • Public Property Raw: Int32 property #

      The value's bits, the value times 65536.

    • Public Method ToDouble(): Double method #

      The value as a Double, which holds it exactly.

    • Public Method ToFloat(): Float method #

      The value as a Float, rounded to the nearest.

    • Public Method ToInt(): Int method #

      The whole part, toward 0, as As takes a Float's.

    • Public Method ToFixed64(): Fixed64 method #

      The value as a Fixed64, which holds it exactly.

    • Public Method ToString(): String method #

      Its value, as the Double it is shows.

    • @PanicsAtCaller Operator +(a: Fixed32, b: Fixed32): Fixed32 operator #

      a plus b. Panics in a debug build when it's past what a Fixed32 holds, and wraps in a release one.

    • @PanicsAtCaller Operator -(a: Fixed32, b: Fixed32): Fixed32 operator #

      a minus b. Panics in a debug build when it's past what a Fixed32 holds, and wraps in a release one.

    • @PanicsAtCaller Operator -(a: Fixed32): Fixed32 operator #

      a negated.

    • Operator <(a: Fixed32, b: Fixed32): Bool operator #

      Whether a is less than b.

    • @PanicsAtCaller Operator *(a: Fixed32, b: Fixed32): Fixed32 operator #

      a times b. Panics in a debug build when it's past what a Fixed32 holds, and wraps in a release one. Rounded to the nearest.

    • @PanicsAtCaller Operator *(a: Fixed32, b: Int): Fixed32 operator #

      a times b.

    • @PanicsAtCaller Operator *(a: Int, b: Fixed32): Fixed32 operator #

      a times b.

    • @PanicsAtCaller Operator /(a: Fixed32, b: Fixed32): Fixed32 operator #

      a divided by b. A b of 0 panics, and a quotient past what it holds does as + does.

    • @PanicsAtCaller Operator /(a: Fixed32, b: Int): Fixed32 operator #

      a divided by b.

    Report an issue with this page or with FutureBlitz on GitHub.