detmath

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package detmath provides FMA-free deterministic math helpers and canonical state hashing shared by physics, physics3d, and vehicle.

Go's arm64 compiler automatically contracts x*y+z into single-rounding FMADD instructions unless an explicit float32/float64 conversion separates the multiply from the add, whereas amd64 uses separate multiply and add instructions. Go's standard library math.Sin, math.Cos, math.Atan2, math.Acos, math.Tan, and math.Hypot also compile with FMADD/FMSUB on arm64. Every function in this package inserts explicit conversions around products so arm64, amd64, and wasm execute identical IEEE-754 rounding bit-for-bit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Acos

func Acos(x float64) float64

Acos returns the arccosine of x in [0, pi] without FMA contraction.

func Atan

func Atan(x float64) float64

Atan returns the arctangent of x in [-pi/2, pi/2] without FMA contraction.

func Atan2

func Atan2(y, x float64) float64

Atan2 returns the arc tangent of y/x using the signs of both to determine the quadrant, without FMA contraction.

func Cos

func Cos(x float64) float64

Cos returns the cosine of x (in radians) without FMA contraction.

func Float32Bits

func Float32Bits(v float32) uint32

Float32Bits returns canonical IEEE-754 bits for hashing: -0.0 maps to +0.0 and any NaN maps to a single quiet NaN bit pattern.

func Float64Bits

func Float64Bits(v float64) uint64

Float64Bits returns canonical IEEE-754 bits for hashing: -0.0 maps to +0.0 and any NaN maps to a single quiet NaN bit pattern.

func Hypot

func Hypot(p, q float64) float64

Hypot returns sqrt(p*p + q*q) without overflow, underflow, or FMA contraction.

func MulAdd32

func MulAdd32(a, b, c float32) float32

MulAdd32 computes float32(a*b) + c without FMA contraction.

func MulAdd64

func MulAdd64(a, b, c float64) float64

MulAdd64 computes float64(a*b) + c without FMA contraction.

func MulSub32

func MulSub32(a, b, c float32) float32

MulSub32 computes float32(a*b) - c without FMA contraction.

func MulSub64

func MulSub64(a, b, c float64) float64

MulSub64 computes float64(a*b) - c without FMA contraction.

func Sin

func Sin(x float64) float64

Sin returns the sine of x (in radians) without FMA contraction.

func Sincos

func Sincos(x float64) (sin, cos float64)

Sincos returns Sin(x), Cos(x) without FMA contraction.

func Tan

func Tan(x float64) float64

Tan returns the tangent of x (in radians) without FMA contraction.

Types

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

Hasher is a zero-allocation streaming 64-bit FNV-1a hasher for deterministic physics world checksums.

func NewHasher

func NewHasher() Hasher

NewHasher returns a new FNV-1a Hasher initialized with the standard 64-bit offset basis.

func (*Hasher) Sum64

func (h *Hasher) Sum64() uint64

Sum64 returns the current 64-bit FNV-1a digest.

func (*Hasher) WriteBool

func (h *Hasher) WriteBool(v bool)

WriteBool mixes one boolean into the hash.

func (*Hasher) WriteFloat32

func (h *Hasher) WriteFloat32(v float32)

WriteFloat32 mixes canonical IEEE-754 float32 bits into the hash.

func (*Hasher) WriteFloat64

func (h *Hasher) WriteFloat64(v float64)

WriteFloat64 mixes canonical IEEE-754 float64 bits into the hash.

func (*Hasher) WriteInt

func (h *Hasher) WriteInt(v int)

WriteInt mixes an int as a fixed-width int64 so 32-bit and 64-bit targets agree.

func (*Hasher) WriteString

func (h *Hasher) WriteString(s string)

WriteString mixes the length and bytes of s into the hash.

func (*Hasher) WriteUint8

func (h *Hasher) WriteUint8(v uint8)

WriteUint8 mixes one byte into the hash.

func (*Hasher) WriteUint32

func (h *Hasher) WriteUint32(v uint32)

WriteUint32 mixes a little-endian uint32 into the hash.

func (*Hasher) WriteUint64

func (h *Hasher) WriteUint64(v uint64)

WriteUint64 mixes a little-endian uint64 into the hash.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL