FixFloat is a deterministic fixed‑point mathematics library designed for high‑performance numerical computation on platforms where floating‑point hardware is either unavailable or insufficiently precise. The library has gained particular prominence in the Unity ecosystem, where it integrates seamlessly with the Burst Compiler and Unity’s Job System to deliver low‑overhead, reproducible arithmetic for both arithmetic and geometric operations.
Historical Context and Motivation
The need for deterministic numerical computation arises in several domains, including multiplayer game networking, scientific simulations, and embedded systems. Traditional IEEE‑754 floating‑point arithmetic, while fast on modern CPUs, suffers from non‑deterministic rounding behavior across different hardware architectures and compiler optimizations. To address these challenges, developers have turned to fixed‑point arithmetic, which represents real numbers as scaled integers, guaranteeing identical results on any platform that adheres to the same integer arithmetic rules.
FixFloat builds upon earlier efforts such as libfixmath and the FixedMath suite, extending them with modern language features (C++20, C# 10) and deep integration with Unity’s Burst Compiler. The library’s design emphasizes:
- Determinism across CPU, GPU, and heterogeneous execution units.
- Compatibility with Unity’s job‑based parallelism.
- Minimal external dependencies (only
stdint.hand a compiler supporting 64‑bit integers). - A familiar API mirroring the standard
math.hfunctions.
Core Design Principles
2.1 Fixed‑Point Representation
The FixFloat struct stores a 64‑bit signed integer (Int64) as the underlying representation. The library adopts a Q16.48 format (16 integer bits, 48 fractional bits) by default, providing:
- Numeric range: approximately
±2²¹(≈ 2,097,152) with a granularity of1/2⁴⁸ ≈ 3.55 × 10⁻¹⁵. - Practical precision of
0.01for values in the range±1,000,000, which satisfies most game‑logic and simulation requirements.
Developers may configure the scaling factor to suit specific domain constraints, trading off range for precision as needed.
2.2 Deterministic Arithmetic
All arithmetic operators (+, –, *, /) are implemented using pure integer operations followed by a deterministic rounding step. Because integer addition, subtraction, and multiplication are defined identically on all two’s‑complement platforms, the resulting calculations are reproducible regardless of:
- CPU micro‑architecture (x86, ARM, RISC‑V).
- Compiler optimization levels.
- Thread scheduling order (when combined with Unity’s deterministic job system).
2.3 Compatibility with Unity Burst
The Burst Compiler translates managed C# code into highly optimized native code, often leveraging SIMD instructions. FixFloat is annotated with Burst‑compatible attributes ([BurstCompile], [MethodImpl(MethodImplOptions.AggressiveInlining)]) to ensure that the generated machine code preserves the deterministic integer pathways while exploiting vectorization where possible.

API Overview
The library mirrors the conventional math.h interface, providing both static utility methods and instance methods on the FixFloat struct.
3.1 Construction and Conversion
public struct FixFloat
{
private long raw; // underlying storage
// Constructors
public FixFloat(int value); // implicit conversion from int
public FixFloat(float value); // conversion with rounding
public static FixFloat FromRaw(long raw); // low‑level construction
// Conversion back to primitive types
public int ToInt const;
public float ToFloat const;
}
3.2 Arithmetic Operations
FixFloat Add(FixFloat other)FixFloat Subtract(FixFloat other)FixFloat Multiply(FixFloat other)FixFloat Divide(FixFloat other)
3.3 Trigonometric and Exponential Functions
For deterministic geometry, FixFloat implements a subset of the standard trigonometric suite using lookup tables and polynomial approximations:
FixFloat Sin(FixFloat angle)FixFloat Cos(FixFloat angle)FixFloat Tan(FixFloat angle)FixFloat Sqrt(FixFloat value)FixFloat Exp(FixFloat exponent)FixFloat Log(FixFloat value)
3.4 Vector and Matrix Utilities
To support geometric calculations, the library supplies fixed‑point vector types (FixFloat2, FixFloat3, FixFloat4) and matrix types (FixFloat4x4) that overload arithmetic operators for concise expression of transformations.
Performance Characteristics
Benchmarking on a mid‑range ARM Cortex‑A78 (2 GHz) versus a desktop Intel i7‑12700K (3.6 GHz) yields the following observations:
- Arithmetic Throughput: Fixed‑point multiplication and division are approximately 1.5–2× slower than native floating‑point on CPUs with a fast FPU, but remain competitive on platforms lacking hardware floating‑point (e.g., microcontrollers, WebAssembly without SIMD).
- Determinism Overhead: The deterministic rounding step adds a negligible (<0.5 µs) per‑operation overhead, dwarfed by the benefits of reproducible results.
- Burst Integration: When compiled with Burst, vectorized fixed‑point operations achieve up to 30 % speed‑up compared with standard C# implementations, owing to SIMD‑friendly integer arithmetic.
Integration Workflow in Unity Projects
5.1 Installation
Include the FixFloat package via Unity’s Package Manager (UPM) by adding the following entry to manifest.json:
{
"dependencies": {
"com.company.fixfloat": "1.2.0"
}
}
5.2 Sample Usage
using FixFloatNamespace;
using Unity.Burst;
using Unity.Jobs;
using Unity.Collections;
[BurstCompile]
public struct PhysicsJob : IJobParallelFor
{
[ReadOnly] public NativeArray positions;
[ReadOnly] public NativeArray velocities;
public NativeArray results;
public FixFloat deltaTime;
public void Execute(int index)
{
// Deterministic position integration
results[index] = positions[index] + velocities[index] * deltaTime;
}
}
The above job demonstrates deterministic integration of motion using FixFloat for both position and velocity vectors.
5.3 Debugging and Validation
Because FixFloat values are stored as integers, developers can inspect the raw long field directly in the Unity debugger, facilitating step‑by‑step verification of rounding behavior.
Comparison with Alternative Fixed‑Point Libraries
| Feature | FixFloat | libfixmath | FixedMath (C#) |
|---|---|---|---|
| Deterministic Guarantees | Yes – integer‑only core | Partial – depends on compiler | Yes – but limited SIMD support |
| Unity Burst Compatibility | Full | No | Limited |
| Range / Precision (default) | ±2²¹ with 1/2⁴⁸ granularity | Q16.16 (≈ 65 536 range, 1/65536 precision) | Configurable Q24.40 |
| API Familiarity | Standard math.h analogues |
C‑style functions | Object‑oriented C# methods |
Best Practices and Common Pitfalls
- Avoid Mixing Types: Do not combine FixFloat with native
floatordoublein the same expression without explicit conversion; this defeats determinism. - Scale Appropriately: Choose a scaling factor that accommodates the expected numeric range while preserving required precision. Over‑scaling can cause overflow; under‑scaling reduces accuracy.
- Pre‑compute Constants: Store frequently used constants (e.g., π, √2) as FixFloat literals to avoid repeated conversion overhead.
- Validate Overflow: Although integer overflow in C# throws an exception only in checked contexts, enable
checkedbuilds during testing to catch inadvertent overflow. - Leverage Burst: Annotate performance‑critical methods with
[BurstCompile]and useUnity.Collectionsnative containers to maximize throughput.
Future Directions
The maintainers of FixFloat have outlined several roadmap items for the upcoming 2.0 release:
- Extended Trigonometric Suite: Inclusion of atan2, asin, acos with higher‑order polynomial approximations.
- Arbitrary Scaling: Runtime‑configurable scaling factors per instance, enabling mixed‑precision calculations within a single project.
- GPU Port: A compute‑shader implementation that mirrors the CPU integer logic, ensuring cross‑platform determinism between CPU and GPU pipelines.
- Static Analysis Tools: Integration with Unity’s Analyzer to flag inadvertent mixing of floating‑point and fixed‑point types.
Conclusion
FixFloat represents a mature, deterministic fixed‑point mathematics solution tailored for modern Unity development. By leveraging a 64‑bit integer backbone, providing a familiar math.h-style API, and ensuring full compatibility with the Burst Compiler, the library empowers developers to achieve reproducible numerical results without sacrificing performance on platforms lacking robust floating‑point units. Its extensibility, clear design principles, and roadmap for






The historical context is well‑crafted. Adding citations to seminal works on deterministic simulation would strengthen academic rigor.
The exposition is technically sound. However, the article could benefit from a dedicated subsection on testing methodologies for deterministic verification.
The coverage of deterministic arithmetic in multiplayer contexts is apt. Including a brief case study of a real‑world game that adopted FixFloat would be illustrative.
The exposition of the Q16.48 format is clear; adding a concise table of numeric limits would aid readers unfamiliar with fixed‑point scaling.
The article mentions minimal dependencies; a list of supported compilers and platforms would assist developers in planning deployments.
The coverage of C 20 and C# 10 language features is appropriate. Yet, a brief note on compatibility with older Unity versions would broaden the audience.
The deterministic guarantees across heterogeneous execution units are compelling. Including performance metrics for GPU execution would substantiate claims.
The description of the Q16.48 format is accurate. A brief explanation of why 48 fractional bits were chosen over alternative configurations would be insightful.
The article’s language is precise, yet occasional typographical errors (e.g., “mo’”) distract from professionalism and should be corrected.
The explanation of the library’s API mirroring math.h functions is helpful. Providing a hyperlink to the official documentation would aid further exploration.
The article provides a comprehensive overview of FixFloat, effectively contextualizing its relevance within deterministic computing. However, a deeper comparison with alternative fixed‑point libraries would enhance its evaluative depth.
Overall, the article is informative and well‑structured. Minor editorial polishing and the suggested supplemental materials would elevate it to an exemplary technical reference.
The precision analysis (0.01 for values up to ±1,000,000) is useful. Including error propagation examples would demonstrate practical implications.
The article’s tone is professional. Minor typographical inconsistencies (e.g., missing spaces after commas) should be corrected for polish.
The integration with Unity’s Job System is described succinctly. Providing sample code that demonstrates parallel execution of FixFloat operations would be valuable.
Integration details with Unity’s Burst Compiler are insightful. Including benchmark figures comparing Burst‑enabled FixFloat against native floating‑point would substantiate performance claims.
The presentation of core design principles is concise. A flowchart illustrating the conversion process between floating‑point and fixed‑point would enhance comprehension.
The historical background is well‑structured, yet the discussion could benefit from citing specific case studies where non‑determinism impacted gameplay outcomes.
The mention of minimal external dependencies is valuable. Providing a minimal build script would assist developers in rapid adoption.
The deterministic guarantees across CPU, GPU, and heterogeneous units are well‑articulated; however, elaborating on synchronization mechanisms would strengthen the argument.
The integration with Unity’s Burst Compiler is highlighted effectively. Discussing any known limitations or edge cases would provide a balanced perspective.
The article’s language is formal and appropriate for a technical audience. Minor grammatical refinements (e.g., consistent use of Oxford commas) would improve consistency.
The API mirroring standard math.h functions is a strong design choice. Including a side‑by‑side code example would illustrate the ease of transition for existing codebases.
The article’s structure is logical. To further aid readers, a summary table contrasting FixFloat with libfixmath and FixedMath would be informative.
The discussion of deterministic rounding is pertinent. Clarifying how the library handles overflow and underflow would enhance robustness.
The article effectively addresses the need for deterministic computation. Including a brief comparison of memory footprints between FixFloat and traditional floating‑point would be advantageous.
The deterministic nature across CPU and GPU is a strong selling point. Including real‑world performance graphs would substantiate the claim.
The article correctly highlights deterministic needs in multiplayer networking. Adding a discussion on latency implications when using fixed‑point arithmetic would be beneficial.
The technical depth is commendable. Adding a short FAQ addressing common integration pitfalls would increase practical utility.
The inclusion of Unity’s Job System compatibility is valuable. Detailing how thread‑safety is ensured within FixFloat operations would be a worthwhile addition.
The article successfully conveys the motivation behind deterministic arithmetic. Adding a brief outlook on future extensions (e.g., support for Q32.32) would be forward‑looking.
The article’s structure follows a logical progression. Adding a concluding section summarizing key takeaways would improve readability.
The narrative flow is coherent. Introducing a concise abstract at the beginning would help readers quickly grasp the article’s scope.
The section on core design principles is thorough. Introducing a diagram of the data flow within the Job System could improve visual comprehension.
The article successfully outlines the library’s motivations. Providing a roadmap for upcoming features (e.g., SIMD acceleration) would engage forward‑looking readers.
The discussion of deterministic rounding is thorough. Clarifying how the library handles NaN or Infinity representations would complete the picture.