lib/math: NAN/INF bits + flattened F64_EXPBIAS (#106 fold-1b)
Flattened from Hare's const struct instances per #129 cgen module-let- init gap; NAN/INF expressed as `def NAN_BITS:u64 = 0x...;` and `def INF_BITS:u64 = 0x...;` materialized via f64frombits(NAN_BITS) at use-site. F64_EXPBIAS:int flattened from f64info.expbias (cite ref/hare/math/floats.ha:117); floatinfo struct definition preserved for γ-cleanup re-fold when #129 closes. F32_EXPBIAS deferred (option-ii: stof.ha consumers reach f.expbias via struct-field only).
This commit is contained in:
@@ -306,6 +306,43 @@ static const struct row rows[] = {
|
||||
" if (readbits(&info) != 23u64) { return 3; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0 },
|
||||
/* --- strconv-foundation fold-1b: NAN_BITS / INF_BITS sentinels.
|
||||
* Hare exports `def NAN = 0.0/0.0;` / `def INF = 1.0/0.0;` (ref/hare/
|
||||
* math/floats.ha:137,141); ww materializes via f64frombits(NAN_BITS)
|
||||
* / f64frombits(INF_BITS) until #129 closes. The bit values are
|
||||
* IEEE-754 facts (quiet-NaN: exp-all-ones + mantissa-MSB; +Inf:
|
||||
* exp-all-ones + mantissa-zero) — any drift means the def-folded
|
||||
* sentinels broke. */
|
||||
{ "package main;\n"
|
||||
"import math;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (math.NAN_BITS != 0x7FF8000000000000u64) { return 1; };\n"
|
||||
" if (math.INF_BITS != 0x7FF0000000000000u64) { return 2; };\n"
|
||||
" let n: f64 = math.f64frombits(math.NAN_BITS);\n"
|
||||
" if (!math.isnan(n)) { return 3; };\n"
|
||||
" if (math.isnan(1.0)) { return 4; };\n"
|
||||
" let i: f64 = math.f64frombits(math.INF_BITS);\n"
|
||||
" if (!math.isinf(i)) { return 5; };\n"
|
||||
" if (!math.isinf(-i)) { return 6; };\n"
|
||||
" if (math.isinf(1.23)) { return 7; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0 },
|
||||
/* F64_EXPBIAS — the f64info.expbias-field-typed counterpart of the
|
||||
* existing F64_EXPONENT_BIAS:u64. Flattened from f64info per #129.
|
||||
* Round-trips into a floatinfo struct's expbias field with zero
|
||||
* casts (the consumer pattern fold-4 stof will use). Cite ref/hare/
|
||||
* math/floats.ha:117 (f64info struct const) + :24 (the existing
|
||||
* untyped F64_EXPONENT_BIAS). */
|
||||
{ "package main;\n"
|
||||
"import math;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (math.F64_EXPBIAS != 1023) { return 1; };\n"
|
||||
" let info: math.floatinfo;\n"
|
||||
" info.expbias = math.F64_EXPBIAS;\n"
|
||||
" if (info.expbias != 1023) { return 2; };\n"
|
||||
" if (info.expbias != math.F64_EXPBIAS) { return 3; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user