From 1cc92bba0f6ee88111c7458ecc61d032679fb848 Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Wed, 14 Oct 2026 13:08:58 +0100 Subject: [PATCH] Report 2026-10.23: Math exports bits, fromBits and mul An F64's bits and back, and the 128-bit product of two U64s, which rjson needs to read and write reals exactly (Eisel-Lemire, Ryu). --- diff --git a/doc/raz-lib.md b/doc/raz-lib.md index 6451c99..0c055d6 100644 --- a/doc/raz-lib.md +++ b/doc/raz-lib.md @@ -443,6 +443,9 @@ proc acos*(x: F64): F64; (* from 0 to pi *) proc atan*(x: F64): F64; (* from -pi/2 to pi/2 *) proc atan2*(y, x: F64): F64; (* the angle of (x, y) from the x axis, from -pi to pi *) +proc bits*(x: F64): U64; (* the bits of x, as IEEE 754 lays them out *) +proc fromBits*(u: U64): F64; (* the F64 whose bits are u *) +proc mul*(a, b: U64): (U64, U64); (* a times b: the low 64 bits of the product, and the high *) ``` A `Buf`, a `List` and a `Map` take their memory from the allocator diff --git a/doc/raz.md b/doc/raz.md index 94fa94d..ac41afb 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -13,7 +13,7 @@ This report defines the language. It is short on purpose. Whatever it doesn't allow, raz doesn't have. -This is version 2026-10.22 of the report; section 11 says where each +This is version 2026-10.23 of the report; section 11 says where each version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler diff --git a/doc/report-history.md b/doc/report-history.md index 563cfa2..09c5b29 100644 --- a/doc/report-history.md +++ b/doc/report-history.md @@ -125,3 +125,6 @@ `conform/` tests (appendix A); the rest of the library is the standard library. The report is in two volumes, `doc/raz.md` and `doc/raz-lib.md`, and its history is here. +- **2026-10.23.** `Math` gains `bits` and `fromBits`, an `F64`'s bits + and back, and `mul`, the 128-bit product of two `U64`s, for reading + and writing reals exactly (volume 2). diff --git a/lib/Math.raz b/lib/Math.raz index 357c657..95c7bff 100644 --- a/lib/Math.raz +++ b/lib/Math.raz @@ -16,14 +16,14 @@ ln2lo = 1.90821492927058770002E-10; (* The bits of x, and the F64 with bits u. *) -proc bits(x: F64): U64; +proc bits*(x: F64): U64; var p: ^U64; begin p := ^U64(ADR(x)); return p^; end; -proc fromBits(u: U64): F64; +proc fromBits*(u: U64): F64; var p: ^F64; begin p := ^F64(ADR(u)); @@ -360,7 +360,7 @@ end; (* a times b: the low 64 bits of the product, and the high. *) -proc mul(a, b: U64): (U64, U64); +proc mul*(a, b: U64): (U64, U64); code mov rax, rdi; mul rsi; diff --git a/src/Raz.raz b/src/Raz.raz index bc847bd..52beac2 100644 --- a/src/Raz.raz +++ b/src/Raz.raz @@ -29,7 +29,7 @@ import Sys, Out, Version, Files, Fmt, Diag, Scan, Sym, Chunk, X64, Gen, Parse, Link, Elf; const - Report = "2026-10.22"; (* the version of doc/raz.md it follows *) + Report = "2026-10.23"; (* the version of doc/raz.md it follows *) MemfdCreate = 319; (* the system call *) MfdCloexec = 1; (* an ELF still executes: the kernel opens it first *) Execve = 59;