float

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const Epsilon float64 = 1e-10

Epsilon is some tiny value that determines how precisely equal we want our floats to be. We've choosen 0.0000000001 (1e-10) as the threshold value.

Variables

This section is empty.

Functions

func AlmostEqual

func AlmostEqual(eps, a, b float64) bool

AlmostEqual determines if a and b are “close enough” using a combination of absolute and relative checks. This version also guards against NaN/Inf edge cases more explicitly, which can avoid subtle pitfalls. It's inspired by code from http://floating-point-gui.de/errors/comparison/

func AlmostEqualPairs

func AlmostEqualPairs(eps float64, f ...float64) bool

AlmostEqualPairs is a utility function to compare pairs of floats.

func Equal

func Equal(a, b float64) bool

Equal is a safe utility function to compare floats. It uses AlmostEqual under the hood with an epsilon of 1e-10

func EqualPairs

func EqualPairs(f ...float64) bool

EqualPairs is a utility function to compare pairs of floats.

Types

This section is empty.

Jump to

Keyboard shortcuts

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