manc provides ancillary math functions for comparing floats in Go.
It has essentially been extracted from the example code of gontract
The function FloatsAreEqual reports if two floats are approximately equal,
taking into account imprecisions of binary representation and rounding.
if manc.FloatsAreEqual(result, expected) {
// Values are approximately equal.
}@@ FloatIsZero
The function `FloatIsZero tests if a float is approximately zero.
if manc.FloatIsZero(num) {
// The number is zero
}For building and testing, manc needs mage installed in the path as it uses a magefile instead of a Makefile.
Examples:
mage test
mage vet
mage check