floatutils

package
v0.1.47 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Float64EqualityThreshold float64 = 1e-9
	Float32EqualityThreshold float32 = 1e-6
)

Variables

View Source
var Float32Infinite = float32(math.Inf(1))
View Source
var Float32Unspecified = float32(math.NaN())
View Source
var Float64Unspecified = math.NaN()
View Source
var FloatInfinite = math.Inf(1)

Functions

func Float32Equals

func Float32Equals(a, b, epsilon float32) bool

floatEquals compares two float32 values with absolute epsilon tolerance.

func Float64Equals

func Float64Equals(a, b, epsilon float64) bool

floatEquals compares two float32 values with absolute epsilon tolerance.

func IsInfinite

func IsInfinite[T Float](f T) bool

func IsNaN

func IsNaN[T Float](f T) bool

Deprecated

func IsSpecified

func IsSpecified[T Float](f T) bool

func IsUnspecified

func IsUnspecified[T Float](f T) bool

func PackFloats

func PackFloats(val1, val2 float32) int64

PackFloats packs two float32 values into a single int64. val1 occupies the higher 32 bits, and val2 occupies the lower 32 bits.

func TakeOrElse

func TakeOrElse[T Float](v T, defaultValue T) T

func UnpackFloat1

func UnpackFloat1(packed int64) float32

UnpackFloat1 extracts the float32 value from the higher 32 bits of the packed int64.

func UnpackFloat2

func UnpackFloat2(packed int64) float32

UnpackFloat2 extracts the float32 value from the lower 32 bits of the packed int64.

Types

type Float

type Float interface {
	~float32 | ~float64
}

Directories

Path Synopsis
Package lerp provides high-performance linear interpolation utilities.
Package lerp provides high-performance linear interpolation utilities.

Jump to

Keyboard shortcuts

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