Table of Contents

Struct FixedPoint32

Namespace
Core.Data
Assembly
Core.dll

32-bit fixed-point number for deterministic calculations Format: 16.16 (16 integer bits, 16 fractional bits) Range: -32,768 to 32,767 with ~0.00002 precision

Use when memory is constrained or smaller range is acceptable. For most simulation math, prefer FixedPoint64 for its larger range.

public struct FixedPoint32

Constructors

FixedPoint32(int)

public FixedPoint32(int rawValue)

Parameters

rawValue int

Fields

Half

public static readonly FixedPoint32 Half

Field Value

FixedPoint32

Hundred

public static readonly FixedPoint32 Hundred

Field Value

FixedPoint32

MaxValue

public static readonly FixedPoint32 MaxValue

Field Value

FixedPoint32

MinValue

public static readonly FixedPoint32 MinValue

Field Value

FixedPoint32

NegativeOne

public static readonly FixedPoint32 NegativeOne

Field Value

FixedPoint32

One

public static readonly FixedPoint32 One

Field Value

FixedPoint32

RawValue

public readonly int RawValue

Field Value

int

Ten

public static readonly FixedPoint32 Ten

Field Value

FixedPoint32

Two

public static readonly FixedPoint32 Two

Field Value

FixedPoint32

Zero

public static readonly FixedPoint32 Zero

Field Value

FixedPoint32

Properties

IsNegative

True if value is less than zero

public bool IsNegative { get; }

Property Value

bool

IsNonNegative

True if value is greater than or equal to zero

public bool IsNonNegative { get; }

Property Value

bool

IsNonPositive

True if value is less than or equal to zero

public bool IsNonPositive { get; }

Property Value

bool

IsPositive

True if value is greater than zero

public bool IsPositive { get; }

Property Value

bool

IsZero

True if value equals zero

public bool IsZero { get; }

Property Value

bool

Sign

Returns the sign: -1, 0, or 1

public int Sign { get; }

Property Value

int

Methods

Abs(FixedPoint32)

public static FixedPoint32 Abs(FixedPoint32 value)

Parameters

value FixedPoint32

Returns

FixedPoint32

Ceiling(FixedPoint32)

Ceiling to nearest integer

public static FixedPoint32 Ceiling(FixedPoint32 value)

Parameters

value FixedPoint32

Returns

FixedPoint32

Clamp(FixedPoint32, FixedPoint32, FixedPoint32)

public static FixedPoint32 Clamp(FixedPoint32 value, FixedPoint32 min, FixedPoint32 max)

Parameters

value FixedPoint32
min FixedPoint32
max FixedPoint32

Returns

FixedPoint32

CompareTo(FixedPoint32)

public int CompareTo(FixedPoint32 other)

Parameters

other FixedPoint32

Returns

int

Equals(FixedPoint32)

public bool Equals(FixedPoint32 other)

Parameters

other FixedPoint32

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Floor(FixedPoint32)

Floor to nearest integer

public static FixedPoint32 Floor(FixedPoint32 value)

Parameters

value FixedPoint32

Returns

FixedPoint32

Frac(FixedPoint32)

Returns the fractional part of the value

public static FixedPoint32 Frac(FixedPoint32 value)

Parameters

value FixedPoint32

Returns

FixedPoint32

FromBytes(byte[], int)

Deserialize from bytes for networking

public static FixedPoint32 FromBytes(byte[] bytes, int offset = 0)

Parameters

bytes byte[]
offset int

Returns

FixedPoint32

FromFixed64(FixedPoint64)

Create from FixedPoint64 (truncates to lower precision)

public static FixedPoint32 FromFixed64(FixedPoint64 value)

Parameters

value FixedPoint64

Returns

FixedPoint32

FromFloat(float)

Create from float (ONLY use during initialization, NEVER in simulation)

public static FixedPoint32 FromFloat(float value)

Parameters

value float

Returns

FixedPoint32

FromFraction(int, int)

Create from fraction (numerator / denominator)

public static FixedPoint32 FromFraction(int numerator, int denominator)

Parameters

numerator int
denominator int

Returns

FixedPoint32

FromInt(int)

Create from integer value

public static FixedPoint32 FromInt(int value)

Parameters

value int

Returns

FixedPoint32

FromRaw(int)

Create from raw fixed-point value (for serialization)

public static FixedPoint32 FromRaw(int raw)

Parameters

raw int

Returns

FixedPoint32

GetHashCode()

public override int GetHashCode()

Returns

int

InverseLerp(FixedPoint32, FixedPoint32, FixedPoint32)

Inverse linear interpolation

public static FixedPoint32 InverseLerp(FixedPoint32 a, FixedPoint32 b, FixedPoint32 value)

Parameters

a FixedPoint32
b FixedPoint32
value FixedPoint32

Returns

FixedPoint32

Lerp(FixedPoint32, FixedPoint32, FixedPoint32)

Linear interpolation: a + (b - a) * t

public static FixedPoint32 Lerp(FixedPoint32 a, FixedPoint32 b, FixedPoint32 t)

Parameters

a FixedPoint32
b FixedPoint32
t FixedPoint32

Returns

FixedPoint32

LerpClamped(FixedPoint32, FixedPoint32, FixedPoint32)

Clamped linear interpolation (t clamped to 0-1)

public static FixedPoint32 LerpClamped(FixedPoint32 a, FixedPoint32 b, FixedPoint32 t)

Parameters

a FixedPoint32
b FixedPoint32
t FixedPoint32

Returns

FixedPoint32

Max(FixedPoint32, FixedPoint32)

public static FixedPoint32 Max(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

FixedPoint32

Min(FixedPoint32, FixedPoint32)

public static FixedPoint32 Min(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

FixedPoint32

MoveTowards(FixedPoint32, FixedPoint32, FixedPoint32)

Move towards target by a maximum delta

public static FixedPoint32 MoveTowards(FixedPoint32 current, FixedPoint32 target, FixedPoint32 maxDelta)

Parameters

current FixedPoint32
target FixedPoint32
maxDelta FixedPoint32

Returns

FixedPoint32

Percentage(FixedPoint32, FixedPoint32)

Percentage: (value / total) * 100

public static FixedPoint32 Percentage(FixedPoint32 value, FixedPoint32 total)

Parameters

value FixedPoint32
total FixedPoint32

Returns

FixedPoint32

Pow(FixedPoint32, int)

Integer exponentiation (value^exponent)

public static FixedPoint32 Pow(FixedPoint32 value, int exponent)

Parameters

value FixedPoint32
exponent int

Returns

FixedPoint32

Remap(FixedPoint32, FixedPoint32, FixedPoint32, FixedPoint32, FixedPoint32)

Remap value from one range to another

public static FixedPoint32 Remap(FixedPoint32 value, FixedPoint32 inMin, FixedPoint32 inMax, FixedPoint32 outMin, FixedPoint32 outMax)

Parameters

value FixedPoint32
inMin FixedPoint32
inMax FixedPoint32
outMin FixedPoint32
outMax FixedPoint32

Returns

FixedPoint32

Round(FixedPoint32)

Round to nearest integer

public static FixedPoint32 Round(FixedPoint32 value)

Parameters

value FixedPoint32

Returns

FixedPoint32

Sqrt(FixedPoint32)

Square root using Newton-Raphson method (deterministic, Burst-compatible) Returns Zero for negative inputs

public static FixedPoint32 Sqrt(FixedPoint32 value)

Parameters

value FixedPoint32

Returns

FixedPoint32

ToBytes()

Serialize to bytes for networking (4 bytes exactly)

public byte[] ToBytes()

Returns

byte[]

ToFixed64()

Convert to FixedPoint64 (lossless upcast)

public FixedPoint64 ToFixed64()

Returns

FixedPoint64

ToFloat()

Convert to float (ONLY for presentation layer, NEVER use result in simulation)

public float ToFloat()

Returns

float

ToInt()

public int ToInt()

Returns

int

ToString()

public override string ToString()

Returns

string

ToString(string)

public string ToString(string format)

Parameters

format string

Returns

string

Operators

operator +(FixedPoint32, FixedPoint32)

public static FixedPoint32 operator +(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

FixedPoint32

operator /(FixedPoint32, FixedPoint32)

public static FixedPoint32 operator /(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

FixedPoint32

operator /(FixedPoint32, int)

public static FixedPoint32 operator /(FixedPoint32 a, int b)

Parameters

a FixedPoint32
b int

Returns

FixedPoint32

operator ==(FixedPoint32, FixedPoint32)

public static bool operator ==(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

bool

operator >(FixedPoint32, FixedPoint32)

public static bool operator >(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

bool

operator >=(FixedPoint32, FixedPoint32)

public static bool operator >=(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

bool

operator !=(FixedPoint32, FixedPoint32)

public static bool operator !=(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

bool

operator <(FixedPoint32, FixedPoint32)

public static bool operator <(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

bool

operator <=(FixedPoint32, FixedPoint32)

public static bool operator <=(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

bool

operator %(FixedPoint32, FixedPoint32)

public static FixedPoint32 operator %(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

FixedPoint32

operator *(FixedPoint32, FixedPoint32)

public static FixedPoint32 operator *(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

FixedPoint32

operator *(FixedPoint32, int)

public static FixedPoint32 operator *(FixedPoint32 a, int b)

Parameters

a FixedPoint32
b int

Returns

FixedPoint32

operator -(FixedPoint32, FixedPoint32)

public static FixedPoint32 operator -(FixedPoint32 a, FixedPoint32 b)

Parameters

a FixedPoint32
b FixedPoint32

Returns

FixedPoint32

operator -(FixedPoint32)

public static FixedPoint32 operator -(FixedPoint32 a)

Parameters

a FixedPoint32

Returns

FixedPoint32