Skip to content

Fixed Point

Struct · FFixedPoint

#include "Types/FixedPoint.h"

deterministic: safe in simulation code

The simulation’s number type: a deterministic 32.32 fixed-point value stored in a 64-bit integer. It holds about plus or minus 2.1 billion with a step of about 2.3e-10, and gives the same result on every machine. Use it instead of float for anything the simulation computes.

int64 Value

Editable in defaults and on instances · Blueprint read and write

The raw storage: the number multiplied by 2^32, so 4294967296 is 1.0. The upper 32 bits are the whole part and the lower 32 the fraction. Use the Make FixedPoint node rather than typing raw values.

C++ members (28)
  • bool Serialize(FArchive& Ar); Native binary serializer (enabled via the TStructOpsTypeTraits below). Writes the raw 32.32 int64, so a TArray<FFixedPoint> — or any FFixedPoint UPROPERTY — serializes as a compact bulk blob instead of a TAGGED reflected struct (which cost ~3-4x per value and made struct-of-FixedPoint arrays bloat ~15x on disk). Determinism-neutral: the int64 value is already platform-stable.
  • operator int64() const; Implicit conversion to int64 for internal operations
  • FFixedPoint operator+(const FFixedPoint& Other) const; Arithmetic overflow is defined as raw modulo-2^64 wrap. This matches the framework’s established Win64 behavior while avoiding signed UB.
  • FFixedPoint operator-(const FFixedPoint& Other) const;
  • FFixedPoint operator-() const;
  • FFixedPoint operator*(const FFixedPoint& Other) const;
  • FFixedPoint operator/(const FFixedPoint& Other) const;
  • bool operator==(const FFixedPoint& Other) const; Comparison operators
  • bool operator!=(const FFixedPoint& Other) const;
  • bool operator<(const FFixedPoint& Other) const;
  • bool operator<=(const FFixedPoint& Other) const;
  • bool operator>(const FFixedPoint& Other) const;
  • bool operator>=(const FFixedPoint& Other) const;
  • static FFixedPoint AddSaturated(FFixedPoint A, FFixedPoint B); A + B clamped to the representable range; operator+ wraps. For stats and other values that must not flip sign on overflow.
  • static FFixedPoint MultiplySaturated(FFixedPoint A, FFixedPoint B); A * B clamped to the representable range; operator* wraps.
  • FFixedPoint& operator+=(const FFixedPoint& Other); Assignment operators
  • FFixedPoint& operator-=(const FFixedPoint& Other);
  • FFixedPoint& operator*=(const FFixedPoint& Other);
  • FFixedPoint& operator/=(const FFixedPoint& Other);
  • static FFixedPoint FromInt(int32 IntValue); Factory methods
  • static FFixedPoint FromInt64(int64 IntValue); Values outside the representable 32-bit integer range retain the established low-32-bit wrapping behavior.
  • static FFixedPoint FromFloat(float FloatValue); WARNING: NON-DETERMINISTIC! Only use for editor/visualization purposes. Floating-point operations may produce different results across platforms/compilers. NEVER use this in simulation logic - use FromInt() instead.
  • int32 ToInt() const; To int32. Be aware of potential overflow if the fixed-point value exceeds the representable range of int32.
  • int64 ToInt64() const; To int64. Be aware of potential overflow if the fixed-point value exceeds the representable range of int64.
  • int32 CeilToInt() const; Ceil to int32 (rounds toward +infinity). Deterministic, integer-only — safe in simulation logic, unlike a ToFloat()-based ceil.
  • float ToFloat() const; To float. WARNING: NON-DETERMINISTIC! Only use for visualization/debugging. DO NOT use in simulation logic - results may vary across platforms.
  • FString ToString() const; To string. WARNING: NON-DETERMINISTIC! Only use for visualization/debugging. DO NOT use in simulation logic - results may vary across platforms.
  • bool IsNearlyEqual(FFixedPoint Other, FFixedPoint Tolerance = FFixedPoint::Epsilon) const; Checks if this fixed-point value is nearly equal to another within a tolerance.