Skip to content
FutureBlitz

    Install

    Import std.math.fixed

    std.math.fixed

    Fixed32 and Fixed64: fixed-point numbers, 16.16 in an Int32 and 32.32 in an Int64, whose math is all integer math, so the same program gives the same bits on every OS and CPU, in debug builds and release, for lockstep multiplayer and replays. * rounds to the nearest, halves up, and / to the nearest, halves away from 0; Sqrt rounds to the nearest; Sin and Cos reduce their angle by Pi / 2 to 94 bits and sum their series in 62, then round, and where that lands too near halfway to tell which way, work it out again in 124 bits, from Pi / 2 to 160. Overflow traps in debug builds and wraps in release, as an Int's does, and dividing by 0 panics.

    std/math/fixed.fb

    Types

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

    std/math/fixed.fb, line 292

    • 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 number that adding leaves alone: 0.

      Doc from std.core.interfaces.Numeric.Zero.

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

      The number that multiplying leaves alone: 1.

      Doc from std.core.interfaces.Numeric.One.

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

      The value to start from, like 0 for a number, "" for a String, or an empty collection.

      Doc from std.core.interfaces.Defaultable.DefaultValue.

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

      The type's lowest value: a float's lowest finite one.

      Doc from std.math.numbers.Bounded.MinValue.

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

      The type's highest value: a float's highest finite one.

      Doc from std.math.numbers.Bounded.MaxValue.

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

      The value as a Double, rounded to the nearest one where a Long's is too large to hold.

      Doc from std.math.numbers.Bounded.DoubleValue.

    • 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 text, as a string interpolation like "{value}" shows it.

      Doc from std.core.interfaces.Printable.ToString.

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

      a and b added up.

      Doc from std.core.interfaces.Numeric.Operator+.

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

      b taken away from a.

      Doc from std.core.interfaces.Numeric.Operator-.

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

      a negated.

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

      Whether a comes before b.

      Doc from std.core.interfaces.Comparable.Operator<.

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

      a and b multiplied together.

      Doc from std.core.interfaces.Numeric.Operator*.

    • @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.

      Doc from std.core.interfaces.Numeric.Operator/.

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

      a divided by b.

    Fixed64 struct

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

    A number with 32 bits for its whole part, its sign among them, and 32 after the point: from -2147483648 to 2147483647.9999999998, in steps of 1 / 4294967296.

    std/math/fixed.fb, line 415

    • Public Static Method FromRaw(bits: Int64): Fixed64 static method #

      The Fixed64 these bits are, as Raw gives them.

    • @PanicsAtCaller Public Static Method FromInt(value: Int64): Fixed64 static method #

      The whole number. One outside an Int's range panics.

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

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

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

      The Float, rounded to the nearest Fixed64. One outside a Fixed64's range, or NaN, panics.

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

      The number that adding leaves alone: 0.

      Doc from std.core.interfaces.Numeric.Zero.

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

      The number that multiplying leaves alone: 1.

      Doc from std.core.interfaces.Numeric.One.

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

      The value to start from, like 0 for a number, "" for a String, or an empty collection.

      Doc from std.core.interfaces.Defaultable.DefaultValue.

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

      The type's lowest value: a float's lowest finite one.

      Doc from std.math.numbers.Bounded.MinValue.

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

      The type's highest value: a float's highest finite one.

      Doc from std.math.numbers.Bounded.MaxValue.

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

      The value as a Double, rounded to the nearest one where a Long's is too large to hold.

      Doc from std.math.numbers.Bounded.DoubleValue.

    • Public Static Property Pi: Fixed64 property #

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

    • Public Static Property Tau: Fixed64 property #

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

    • Public Property Raw: Int64 property #

      The value's bits, the value times 4294967296.

    • Public Method ToDouble(): Double method #

      The value as a Double, rounded to the nearest, which holds it exactly up to 2^21.

    • Public Method ToFloat(): Float method #

      The value as a Float, rounded to the nearest: once, from the bits, since a Double of them can round already.

    • Public Method ToInt(): Int method #

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

    • @PanicsAtCaller Public Method ToFixed32(): Fixed32 method #

      The value as a Fixed32, rounded to the nearest, halves up. One outside a Fixed32's range overflows, as Narrowed says.

    • Public Method ToString(): String method #

      The value in decimal, from its bits: its whole part, and the fewest digits after the point that are nearer it than any other Fixed64, so no two print alike and none prints past what it holds.

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

      a and b added up.

      Doc from std.core.interfaces.Numeric.Operator+.

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

      b taken away from a.

      Doc from std.core.interfaces.Numeric.Operator-.

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

      a negated.

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

      Whether a comes before b.

      Doc from std.core.interfaces.Comparable.Operator<.

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

      a and b multiplied together.

      Doc from std.core.interfaces.Numeric.Operator*.

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

      a times b.

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

      a times b.

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

      a divided by b.

      Doc from std.core.interfaces.Numeric.Operator/.

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

      a divided by b.

    Functions

    Sqrt function

    @PanicsAtCaller Public Function Sqrt(value: Fixed32): Fixed32

    The square root, rounded to the nearest. A negative value panics.

    std/math/fixed.fb, line 553

    Sqrt function

    @PanicsAtCaller Public Function Sqrt(value: Fixed64): Fixed64

    The square root, rounded to the nearest. A negative value panics.

    std/math/fixed.fb, line 563

    Sin function

    Public Function Sin(angle: Fixed32): Fixed32

    The sine of an angle in radians, the same bits everywhere.

    std/math/fixed.fb, line 592

    Cos function

    Public Function Cos(angle: Fixed32): Fixed32

    The cosine of an angle in radians, the same bits everywhere.

    std/math/fixed.fb, line 597

    Sin function

    Public Function Sin(angle: Fixed64): Fixed64

    The sine of an angle in radians, the same bits everywhere.

    std/math/fixed.fb, line 602

    Cos function

    Public Function Cos(angle: Fixed64): Fixed64

    The cosine of an angle in radians, the same bits everywhere.

    std/math/fixed.fb, line 607

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