diff --git a/examples/0159-types-float-numeric-limits.sx b/examples/0159-types-float-numeric-limits.sx index f2753ab..dc82d7c 100644 --- a/examples/0159-types-float-numeric-limits.sx +++ b/examples/0159-types-float-numeric-limits.sx @@ -25,10 +25,11 @@ #import "modules/std.sx"; // `bits` mirrors each float's raw IEEE-754 storage. f64 needs 64 bits, f32 32. -// The f64 union uses a `u64` view so the all-ones-ish positive patterns read as -// their true magnitude; the negative `f64.min` pattern (0xFFEF…) overflows the -// i64 literal parser, so it is pinned by the `min == -max` property instead. -Uf64 :: union { f: f64; bits: u64; } +// The f64 union's `bits` (u64) view reads the all-ones-ish positive patterns as +// their true magnitude; its `s` (s64) view pins the negative `f64.min` pattern +// (0xFFEF…), whose unsigned form overflows the u64 literal parser, by comparing +// the signed reinterpret to -4503599627370497. +Uf64 :: union { f: f64; bits: u64; s: s64; } Uf32 :: union { f: f32; bits: u32; } main :: () -> s32 { @@ -43,6 +44,10 @@ main :: () -> s32 { o.f = f64.max; print("f64.max {}\n", o.bits == 0x7FEFFFFFFFFFFFFF); // true + // f64.min = -max; its bit pattern 0xFFEFFFFFFFFFFFFF overflows an unsigned u64 + // literal, so it is pinned directly via the SIGNED s64 view: -4503599627370497. + o.f = f64.min; + print("f64.min {}\n", o.s == -4503599627370497); // true (bits 0xFFEFFFFFFFFFFFFF) o.f = f64.epsilon; print("f64.epsilon {}\n", o.bits == 0x3CB0000000000000); // true o.f = f64.min_positive; diff --git a/examples/expected/0159-types-float-numeric-limits.stdout b/examples/expected/0159-types-float-numeric-limits.stdout index f562d64..b6c69f5 100644 --- a/examples/expected/0159-types-float-numeric-limits.stdout +++ b/examples/expected/0159-types-float-numeric-limits.stdout @@ -1,5 +1,6 @@ f64.true_min true f64.max true +f64.min true f64.epsilon true f64.min_positive true f64.inf true