commit d34aef69506b3223b5c55abf8debf4632c88e691
parent 60d9587d71d30d6eba5e273ccd1bd172d2728a8b
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date: Wed, 26 Jan 2022 16:51:40 +0100
math: constants for smallest representable positive offset from 1
Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/math/floats.ha b/math/floats.ha
@@ -63,9 +63,13 @@ export def F64_MAX_NORMAL: f64 = 1.7976931348623157e+308;
// The smallest representable normal f64 value.
export def F64_MIN_NORMAL: f64 = 2.2250738585072014e-308;
-// THe smallest (subnormal) f64 value greater than zero.
+// The smallest (subnormal) f64 value greater than zero.
export def F64_MIN: f64 = 5.0e-324;
+// The difference between 1 and the smallest f64 representable value that is
+// greater than 1.
+export def F64_EPS: f64 = 2.22040000000000004884e-16;
+
// The largest representable f32 value which is less than Infinity.
export def F32_MAX_NORMAL: f32 = 3.4028234e+38;
@@ -75,6 +79,10 @@ export def F32_MIN_NORMAL: f32 = 1.1754944e-38;
// The smallest (subnormal) f32 value greater than zero.
export def F32_MIN: f32 = 1.0e-45;
+// The difference between 1 and the smallest f32 representable value that is
+// greater than 1.
+export def F32_EPS: f32 = 1.1920928955078125e-7;
+
// The mask that gets an f64's sign.
def F64_SIGN_MASK: u64 = 1u64 << 63;