Table of Contents

Struct FixedPoint64

Namespace
Core.Data
Assembly
Core.dll

64-bit fixed-point number for deterministic calculations across all platforms Format: 32.32 (32 integer bits, 32 fractional bits) Range: -2,147,483,648 to 2,147,483,647 with ~0.0000000002 precision

CRITICAL: This type is used for ALL simulation math to ensure multiplayer determinism. Float operations produce different results on different CPUs/compilers. Fixed-point math guarantees identical results across all platforms.

public struct FixedPoint64

Fields

Half

public static readonly FixedPoint64 Half

Field Value

FixedPoint64

Hundred

public static readonly FixedPoint64 Hundred

Field Value

FixedPoint64

MaxValue

public static readonly FixedPoint64 MaxValue

Field Value

FixedPoint64

MinValue

public static readonly FixedPoint64 MinValue

Field Value

FixedPoint64

NegativeOne

public static readonly FixedPoint64 NegativeOne

Field Value

FixedPoint64

One

public static readonly FixedPoint64 One

Field Value

FixedPoint64

RawValue

public readonly long RawValue

Field Value

long

Ten

public static readonly FixedPoint64 Ten

Field Value

FixedPoint64

Two

public static readonly FixedPoint64 Two

Field Value

FixedPoint64

Zero

public static readonly FixedPoint64 Zero

Field Value

FixedPoint64

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(FixedPoint64)

Returns the absolute value.

public static FixedPoint64 Abs(FixedPoint64 value)

Parameters

value FixedPoint64

Returns

FixedPoint64

Ceiling(FixedPoint64)

Ceiling to nearest integer

public static FixedPoint64 Ceiling(FixedPoint64 value)

Parameters

value FixedPoint64

Returns

FixedPoint64

Clamp(FixedPoint64, FixedPoint64, FixedPoint64)

Clamps a value to the specified range.

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

Parameters

value FixedPoint64
min FixedPoint64
max FixedPoint64

Returns

FixedPoint64

CompareTo(FixedPoint64)

public int CompareTo(FixedPoint64 other)

Parameters

other FixedPoint64

Returns

int

Equals(FixedPoint64)

public bool Equals(FixedPoint64 other)

Parameters

other FixedPoint64

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Floor(FixedPoint64)

Floor to nearest integer

public static FixedPoint64 Floor(FixedPoint64 value)

Parameters

value FixedPoint64

Returns

FixedPoint64

Frac(FixedPoint64)

Returns the fractional part of the value (0 to 0.999...)

public static FixedPoint64 Frac(FixedPoint64 value)

Parameters

value FixedPoint64

Returns

FixedPoint64

FromBytes(byte[], int)

Deserialize from bytes for networking

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

Parameters

bytes byte[]
offset int

Returns

FixedPoint64

FromDouble(double)

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

public static FixedPoint64 FromDouble(double value)

Parameters

value double

Returns

FixedPoint64

FromFloat(float)

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

public static FixedPoint64 FromFloat(float value)

Parameters

value float

Returns

FixedPoint64

FromFraction(long, long)

Create from fraction (numerator / denominator)

public static FixedPoint64 FromFraction(long numerator, long denominator)

Parameters

numerator long
denominator long

Returns

FixedPoint64

FromInt(int)

Create from integer value

public static FixedPoint64 FromInt(int value)

Parameters

value int

Returns

FixedPoint64

FromLong(long)

Create from long integer value

public static FixedPoint64 FromLong(long value)

Parameters

value long

Returns

FixedPoint64

FromRaw(long)

Create from raw fixed-point value (for serialization)

public static FixedPoint64 FromRaw(long raw)

Parameters

raw long

Returns

FixedPoint64

GetHashCode()

public override int GetHashCode()

Returns

int

InverseLerp(FixedPoint64, FixedPoint64, FixedPoint64)

Inverse linear interpolation: returns t where Lerp(a, b, t) = value Returns 0 if a == b

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

Parameters

a FixedPoint64
b FixedPoint64
value FixedPoint64

Returns

FixedPoint64

Lerp(FixedPoint64, FixedPoint64, FixedPoint64)

Linear interpolation: a + (b - a) * t When t=0 returns a, when t=1 returns b

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

Parameters

a FixedPoint64
b FixedPoint64
t FixedPoint64

Returns

FixedPoint64

LerpClamped(FixedPoint64, FixedPoint64, FixedPoint64)

Clamped linear interpolation (t clamped to 0-1)

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

Parameters

a FixedPoint64
b FixedPoint64
t FixedPoint64

Returns

FixedPoint64

Max(FixedPoint64, FixedPoint64)

Returns the larger of two values.

public static FixedPoint64 Max(FixedPoint64 a, FixedPoint64 b)

Parameters

a FixedPoint64
b FixedPoint64

Returns

FixedPoint64

Min(FixedPoint64, FixedPoint64)

Returns the smaller of two values.

public static FixedPoint64 Min(FixedPoint64 a, FixedPoint64 b)

Parameters

a FixedPoint64
b FixedPoint64

Returns

FixedPoint64

MoveTowards(FixedPoint64, FixedPoint64, FixedPoint64)

Move towards target by a maximum delta

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

Parameters

current FixedPoint64
target FixedPoint64
maxDelta FixedPoint64

Returns

FixedPoint64

Percentage(FixedPoint64, FixedPoint64)

Percentage: (value / total) * 100 Returns Zero if total is zero

public static FixedPoint64 Percentage(FixedPoint64 value, FixedPoint64 total)

Parameters

value FixedPoint64
total FixedPoint64

Returns

FixedPoint64

Pow(FixedPoint64, int)

Integer exponentiation (value^exponent) Deterministic, handles negative exponents

public static FixedPoint64 Pow(FixedPoint64 value, int exponent)

Parameters

value FixedPoint64
exponent int

Returns

FixedPoint64

Remap(FixedPoint64, FixedPoint64, FixedPoint64, FixedPoint64, FixedPoint64)

Remap value from one range to another Example: Remap(50, 0, 100, 0, 1) = 0.5

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

Parameters

value FixedPoint64
inMin FixedPoint64
inMax FixedPoint64
outMin FixedPoint64
outMax FixedPoint64

Returns

FixedPoint64

RemapClamped(FixedPoint64, FixedPoint64, FixedPoint64, FixedPoint64, FixedPoint64)

Remap with clamping (output clamped to outMin-outMax range)

public static FixedPoint64 RemapClamped(FixedPoint64 value, FixedPoint64 inMin, FixedPoint64 inMax, FixedPoint64 outMin, FixedPoint64 outMax)

Parameters

value FixedPoint64
inMin FixedPoint64
inMax FixedPoint64
outMin FixedPoint64
outMax FixedPoint64

Returns

FixedPoint64

Round(FixedPoint64)

Round to nearest integer

public static FixedPoint64 Round(FixedPoint64 value)

Parameters

value FixedPoint64

Returns

FixedPoint64

Sqrt(FixedPoint64)

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

public static FixedPoint64 Sqrt(FixedPoint64 value)

Parameters

value FixedPoint64

Returns

FixedPoint64

ToBytes()

Serialize to bytes for networking (8 bytes exactly)

public byte[] ToBytes()

Returns

byte[]

ToDouble()

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

public double ToDouble()

Returns

double

ToFloat()

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

public float ToFloat()

Returns

float

ToInt()

Truncates to integer (rounds toward zero).

public int ToInt()

Returns

int

ToLong()

Truncates to long integer (rounds toward zero).

public long ToLong()

Returns

long

ToString()

public override string ToString()

Returns

string

ToString(string)

public string ToString(string format)

Parameters

format string

Returns

string

Operators

operator +(FixedPoint64, FixedPoint64)

Adds two fixed-point values.

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

FixedPoint64

operator /(FixedPoint64, FixedPoint64)

Divides two fixed-point values. Throws DivideByZeroException if divisor is zero.

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

FixedPoint64

operator /(FixedPoint64, int)

Divides by an integer (more efficient than FixedPoint64 division).

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

Parameters

a FixedPoint64
b int

Returns

FixedPoint64

operator ==(FixedPoint64, FixedPoint64)

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

bool

operator >(FixedPoint64, FixedPoint64)

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

bool

operator >=(FixedPoint64, FixedPoint64)

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

bool

operator !=(FixedPoint64, FixedPoint64)

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

bool

operator <(FixedPoint64, FixedPoint64)

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

bool

operator <=(FixedPoint64, FixedPoint64)

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

bool

operator %(FixedPoint64, FixedPoint64)

Returns the remainder after division.

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

FixedPoint64

operator *(FixedPoint64, FixedPoint64)

Multiplies two fixed-point values using 128-bit intermediate to prevent overflow.

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

FixedPoint64

operator *(FixedPoint64, int)

Multiplies by an integer (more efficient than FixedPoint64 multiplication).

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

Parameters

a FixedPoint64
b int

Returns

FixedPoint64

operator -(FixedPoint64, FixedPoint64)

Subtracts two fixed-point values.

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

Parameters

a FixedPoint64
b FixedPoint64

Returns

FixedPoint64

operator -(FixedPoint64)

Negates a fixed-point value.

public static FixedPoint64 operator -(FixedPoint64 a)

Parameters

a FixedPoint64

Returns

FixedPoint64