lib/math: inline floats f64bits/f64frombits reinterpret deref
Mirror Hare's single-expression `*(&n: *T)` structure (CLAUDE.md rule 12) instead of a let-temp two-step that added a binding Hare has no counterpart for. Document the load-bearing parens (rule 8): ww's `:` cast binds tighter than unary `&`, so the bare Hare form parses as `*(&(n: *T))`; `(&n): *T` is what reinterprets the address. ref/hare/math/floats.ha:5,11. Byte-identical both stages; 952 6/6.
This commit is contained in:
@@ -6,17 +6,17 @@
|
||||
package math;
|
||||
|
||||
// Returns the binary representation of the given f64.
|
||||
// ref/hare/math/floats.ha:5
|
||||
// ref/hare/math/floats.ha:5. Parens around &n are load-bearing: ww's `:`
|
||||
// cast binds tighter than unary `&`, so Hare's `*(&n: *u64)` would parse
|
||||
// as `*(&(n: *u64))`; `(&n): *u64` reinterprets the address as intended.
|
||||
export fn f64bits(n: f64) u64 = {
|
||||
let p: *u64 = (&n): *u64;
|
||||
return *p;
|
||||
return *((&n): *u64);
|
||||
};
|
||||
|
||||
// Returns f64 with the given binary representation.
|
||||
// ref/hare/math/floats.ha:11
|
||||
export fn f64frombits(n: u64) f64 = {
|
||||
let p: *f64 = (&n): *f64;
|
||||
return *p;
|
||||
return *((&n): *f64);
|
||||
};
|
||||
|
||||
// ref/hare/math/floats.ha:17,20,23 declare these as untyped int. ww has
|
||||
|
||||
Reference in New Issue
Block a user