From 745e64751b2ee5ca2caab6d2d9e13e062cac460a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 8 Dec 2024 13:51:03 +0900 Subject: [PATCH] Add new procedures `binary64-exponent` and `binary64-integer-exponent` Signed-off-by: yamacir-kit --- README.md | 4 ++-- VERSION | 2 +- basis/srfi-144.ss | 9 +++++++-- src/kernel/boot.cpp | 10 ++++++++++ test/srfi-144.ss | 10 +++++++++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a86a6feab..2684bbbe5 100644 --- a/README.md +++ b/README.md @@ -97,9 +97,9 @@ Then, select one of the following targets and `make` it according to your purpos | Target | Description |-------------|------------- -| `all` | Build shared-library `libmeevax.0.5.283.so` and executable `meevax`. +| `all` | Build shared-library `libmeevax.0.5.284.so` and executable `meevax`. | `install` | Copy files into `/usr/local` directly. -| `package` | Generate debian package `meevax_0.5.283_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.283_amd64.deb`. +| `package` | Generate debian package `meevax_0.5.284_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.284_amd64.deb`. | `test` | Test executable `meevax`. This target requires Valgrind to be installed. | `uninstall` | Remove files copied to `/usr/local` directly by target `install`. diff --git a/VERSION b/VERSION index d086d766d..97bd45ba8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.283 +0.5.284 diff --git a/basis/srfi-144.ss b/basis/srfi-144.ss index 13875d113..3605b85f7 100644 --- a/basis/srfi-144.ss +++ b/basis/srfi-144.ss @@ -4,7 +4,9 @@ FP_ILOGB0 FP_ILOGBNAN binary64-epsilon + binary64-exponent binary64-fractional-part + binary64-integer-exponent binary64-integral-part binary64-max binary64-min @@ -45,8 +47,7 @@ flonum fladjacent flcopysign make-flonum - flinteger-fraction - ; flexponent flinteger-exponent + flinteger-fraction flexponent flinteger-exponent ; flnormalized-fraction-exponent flsign-bit ; ; flonum? fl=? fl? fl<=? fl>=? @@ -171,5 +172,9 @@ (define (flinteger-fraction x) (values (binary64-integral-part x) (binary64-fractional-part x))) + + (define flexponent binary64-exponent) + + (define flinteger-exponent binary64-integer-exponent) ) ) diff --git a/src/kernel/boot.cpp b/src/kernel/boot.cpp index a8667c6f7..b81e4f1f9 100644 --- a/src/kernel/boot.cpp +++ b/src/kernel/boot.cpp @@ -583,6 +583,16 @@ namespace meevax::inline kernel return make(std::modf(car(xs).as(), &integral_part)); }); + library.define("binary64-exponent", [](let const& xs) + { + return make(std::logb(car(xs).as())); + }); + + library.define("binary64-integer-exponent", [](let const& xs) + { + return make(std::ilogb(car(xs).as())); + }); + library.define("e", std::numbers::e); library.define("pi", std::numbers::pi); diff --git a/test/srfi-144.ss b/test/srfi-144.ss index f4600cf26..cfca79f76 100644 --- a/test/srfi-144.ss +++ b/test/srfi-144.ss @@ -128,6 +128,14 @@ (check integral (=> =) 3.0) (check fractional (=> =) 0.14))) +(check (flexponent 48.0) => 5.0) + +(check (flexponent -48.0) => 5.0) + +(check (flinteger-exponent 48.0) => 5) + +(check (flinteger-exponent -48.0) => 5) + (check-report) -(exit (check-passed? 61)) +(exit (check-passed? 65))