hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 0074767cf612e6f965a68a95cd9e53a0e0abda50
parent d922eafdc52004801a96546555ad9286d5ea1b97
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sun,  1 Dec 2024 20:25:29 -0500

math: rename F(32|64)_MIN to F(32|64)_MIN_SUBNORMAL

The previous name was confusing, because it looks similar to the
types::*_MIN constants, but isn't the same. The new name (similar to
F(32|64)_MIN_NORMAL) better reflects the actual purpose.

This is a breaking change.

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mmath/+test/floats_test.ha | 4++--
Mmath/floats.ha | 4++--
Mstrconv/+test/ftos_test.ha | 12++++++------
Mstrconv/stof.ha | 4++--
4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/math/+test/floats_test.ha b/math/+test/floats_test.ha @@ -3,12 +3,12 @@ @test fn floatbits() void = { const a: [_]f64 = [INF, -INF, 0.0, 1.0, -1.0, 123456789.0, - F64_MIN, F64_MIN_NORMAL, F64_MAX_NORMAL]; + F64_MIN_SUBNORMAL, F64_MIN_NORMAL, F64_MAX_NORMAL]; for (let i = 0z; i < len(a); i += 1) { assert(f64frombits(f64bits(a[i])) == a[i]); }; const a: [_]f32 = [INF, -INF, 0.0, 1.0, -1.0, -123456.0, - F32_MIN, F32_MIN_NORMAL, F32_MAX_NORMAL]; + F32_MIN_SUBNORMAL, F32_MIN_NORMAL, F32_MAX_NORMAL]; for (let i = 0z; i < len(a); i += 1) { assert(f32frombits(f32bits(a[i])) == a[i]); }; diff --git a/math/floats.ha b/math/floats.ha @@ -52,7 +52,7 @@ export def F64_MAX_NORMAL: f64 = 1.7976931348623157e+308; export def F64_MIN_NORMAL: f64 = 2.2250738585072014e-308; // The smallest (subnormal) f64 value greater than zero. -export def F64_MIN: f64 = 5.0e-324; +export def F64_MIN_SUBNORMAL: f64 = 5.0e-324; // The difference between 1 and the smallest f64 representable value that is // greater than 1. @@ -65,7 +65,7 @@ export def F32_MAX_NORMAL: f32 = 3.4028234e+38; 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; +export def F32_MIN_SUBNORMAL: f32 = 1.0e-45; // The difference between 1 and the smallest f32 representable value that is // greater than 1. diff --git a/strconv/+test/ftos_test.ha b/strconv/+test/ftos_test.ha @@ -197,12 +197,12 @@ use memio; (9007199254740991.0, ffmt::F, void, 0, "9007199254740991"), (90071992547409915.0, ffmt::F, void, 0, "90071992547409920"), (90071992547409925.0, ffmt::F, void, 0, "90071992547409920"), - (math::F64_MIN, ffmt::E, void, 0, "5e-324"), - (math::F64_MIN, ffmt::E, void, fflags::SHOW_TWO_EXP_DIGITS, "5e-324"), - (-math::F64_MIN, ffmt::E, void, 0, "-5e-324"), + (math::F64_MIN_SUBNORMAL, ffmt::E, void, 0, "5e-324"), + (math::F64_MIN_SUBNORMAL, ffmt::E, void, fflags::SHOW_TWO_EXP_DIGITS, "5e-324"), + (-math::F64_MIN_SUBNORMAL, ffmt::E, void, 0, "-5e-324"), (math::F64_MIN_NORMAL, ffmt::E, void, 0, "2.2250738585072014e-308"), (math::F64_MAX_NORMAL, ffmt::E, void, 0, "1.7976931348623157e308"), - (math::F64_MIN, ffmt::E, 2, 0, "4.94e-324"), + (math::F64_MIN_SUBNORMAL, ffmt::E, 2, 0, "4.94e-324"), (math::F64_MIN_NORMAL, ffmt::E, 0, 0, "2e-308"), (math::F64_MAX_NORMAL, ffmt::E, 3, 0, "1.798e308"), ]; @@ -216,7 +216,7 @@ use memio; }; // These tests will only pass for f32 const tcsf32: [](f32, ffmt, (void | uint), fflags, str) = [ - (math::F32_MIN, ffmt::G, void, 0, "1e-45"), + (math::F32_MIN_SUBNORMAL, ffmt::G, void, 0, "1e-45"), (math::F32_MIN_NORMAL, ffmt::G, void, 0, "1.1754944e-38"), (math::F32_MAX_NORMAL, ffmt::G, void, 0, "3.4028235e38"), ]; @@ -231,7 +231,7 @@ use memio; // Just make sure we can generate big numbers without breaking anything. const tcslen: [](f64, ffmt, (void | uint), fflags, size) = [ (9007199254740991.0, ffmt::F, void, 0, 16), - (-math::F64_MIN, ffmt::E, 100, 0, 108), + (-math::F64_MIN_SUBNORMAL, ffmt::E, 100, 0, 108), (1.0, ffmt::F, 1000, 0, 1002), (2.22507385850720088902458687609E-308, ffmt::F, 1000, 0, 1002), ]; diff --git a/strconv/stof.ha b/strconv/stof.ha @@ -597,7 +597,7 @@ export fn stof32(s: str, b: base = base::DEC) (f32 | invalid | overflow) = { assert(stof64("1.0000000000000p-1022", base::HEX)! == math::F64_MIN_NORMAL); assert(stof64("0.0000000000001p-1022", base::HEX)! - == math::F64_MIN); + == math::F64_MIN_SUBNORMAL); assert(stof64("1p+1024", base::HEX) is overflow); assert(stof64("0.00000000000001p-1022", base::HEX)! == 0.0); @@ -608,7 +608,7 @@ export fn stof32(s: str, b: base = base::DEC) (f32 | invalid | overflow) = { assert(stof32("1.fffffd586b834p+127", base::HEX)! == math::F32_MAX_NORMAL); assert(stof32("1.0p-126", base::HEX)! == math::F32_MIN_NORMAL); - assert(stof32("1.6p-150", base::HEX)! == math::F32_MIN); + assert(stof32("1.6p-150", base::HEX)! == math::F32_MIN_SUBNORMAL); assert(stof32("1.0p+128", base::HEX) is overflow); assert(stof32("1.0p-151", base::HEX)! == 0.0); };