Import std.math.fixed
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.
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)-
The Fixed32 these
bitsare, as Raw gives them. -
The whole number. One outside -32768 to 32767 panics.
-
The Double, rounded to the nearest Fixed32, halves away from 0. One outside a Fixed32's range, or NaN, panics.
-
The Float, rounded to the nearest Fixed32, halves away from 0. One outside a Fixed32's range, or NaN, panics.
-
The zero Fixed32, which adding leaves alone.
-
The Fixed32 1, raw 65536, which multiplying leaves alone.
-
The zero Fixed32.
-
The lowest Fixed32, -32768.
-
The highest Fixed32, about 32767.99998.
-
The
valueas a Double, which holds every one exactly. -
Pi, and a turn, 2 Pi, rounded to a Fixed32's steps.
-
A turn, 2 Pi, rounded to a Fixed32's steps.
-
The value's bits, the value times 65536.
-
The value as a Double, which holds it exactly.
-
The value as a Float, rounded to the nearest.
-
The whole part, toward 0, as As takes a Float's.
-
The value as a Fixed64, which holds it exactly.
-
Its value, as the Double it is shows.
-
aplusb. Panics in a debug build when it's past what a Fixed32 holds, and wraps in a release one. -
aminusb. Panics in a debug build when it's past what a Fixed32 holds, and wraps in a release one. -
anegated. -
Whether
ais less thanb. -
atimesb. Panics in a debug build when it's past what a Fixed32 holds, and wraps in a release one. Rounded to the nearest. -
atimesb. -
atimesb. -
adivided byb. Abof 0 panics, and a quotient past what it holds does as + does. -
adivided byb.
Report an issue with this page or with FutureBlitz on GitHub.