Skip to content

Repository files navigation

FixedMathSharp

FixedMathSharp icon

Build Core Branch Coverage NuGet License Discord

Deterministic fixed-point math for .NET games, simulations, procedural generation, tooling, and replays.

FixedMathSharp gives you a practical Q32.32 numeric stack—from scalar math and random streams to vectors, transforms, and geometry—without tying your runtime to a game engine. The same inputs follow the same integer-backed math path, which makes the library a strong fit for lockstep simulation, reproducible world generation, and replayable systems.

Why use it?

  • Deterministic by design. Fixed64 uses an explicit Q32.32 representation with documented rounding and overflow behavior.
  • A complete math toolbox. Vectors, matrices, quaternions, transforms, curves, bounds, rays, segments, triangles, and deterministic random streams share one numeric model.
  • Built for difficult inputs. Full-domain intermediate arithmetic prevents premature saturation in fused math, transforms, and geometry queries.
  • Engine-agnostic. The core stays portable; engine conventions and interop live at adapter boundaries.
  • Serialization choices. Use the standard MemoryPack-enabled package or the Lean variant with no direct MemoryPack dependency.

Install

dotnet add package FixedMathSharp

Targeting Unity? Use the dedicated FixedMathSharp-Unity packages, including a Lean package for Burst-oriented projects.

Quick start

using FixedMathSharp;
using FixedMathSharp.Geometry;

Fixed64 tick = Fixed64.One / 60;
Vector3d velocity = new(6, 0, 2);
Vector3d nextPosition = velocity * tick;

FixedQuaternion turn = FixedQuaternion.FromAxisAngle(
    Vector3d.Up,
    Fixed64.PiOver4);

Vector3d heading = turn.Rotate(Vector3d.Forward);
FixedBoundSphere playArea = new(Vector3d.Zero, new Fixed64(100));

bool inside = playArea.Contains(nextPosition);

All values in the simulation-facing calculation remain fixed point. Convert to float or double only at rendering, editor, or external API boundaries.

Pick a package

Package Use it for
FixedMathSharp Core math with MemoryPack support
FixedMathSharp.Lean The same math surface without a direct MemoryPack dependency
FixedMathSharp.Chronicler Deterministic record hashes for replay and conformance tooling
FixedMathSharp.Chronicler.Lean Chronicler extensions on the Lean dependency graph
FixedMathSharp.FluentAssertions Fluent assertions for fixed-point tests
FixedMathSharp.FluentAssertions.Lean Fluent assertions paired with the Lean package

Published packages target .NET Standard 2.1 and .NET 8.

Explore the library

  • Getting started — package choice, setup, examples, serialization, and source builds
  • Wiki — numeric behavior, transforms, conventions, geometry, and formatting
  • API reference — public types and members generated from the source XML documentation
  • Migration guide — intentional breaking changes and upgrade guidance
  • Benchmarks — reproducible BenchmarkDotNet workflows and evidence rules

Community and contributions

Bug reports, feature requests, performance evidence, and real-world determinism stories are welcome. Read CONTRIBUTING.md before opening a pull request, or join the Discord community.

FixedMathSharp is available under the MIT License. See NOTICE for the project branding and redistribution terms.

Releases

Sponsor this project

Used by

Contributors

Languages