Skip to content

Commit

Permalink
Add new procedures binary64-exponent and binary64-integer-exponent
Browse files Browse the repository at this point in the history
Signed-off-by: yamacir-kit <[email protected]>
  • Loading branch information
yamacir-kit committed Dec 8, 2024
1 parent cfa6b02 commit 745e647
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.283
0.5.284
9 changes: 7 additions & 2 deletions basis/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<=? fl>=?
Expand Down Expand Up @@ -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)
)
)
10 changes: 10 additions & 0 deletions src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,16 @@ namespace meevax::inline kernel
return make(std::modf(car(xs).as<double>(), &integral_part));
});

library.define<procedure>("binary64-exponent", [](let const& xs)
{
return make(std::logb(car(xs).as<double>()));
});

library.define<procedure>("binary64-integer-exponent", [](let const& xs)
{
return make<exact_integer>(std::ilogb(car(xs).as<double>()));
});

library.define<double>("e", std::numbers::e);

library.define<double>("pi", std::numbers::pi);
Expand Down
10 changes: 9 additions & 1 deletion test/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit 745e647

Please sign in to comment.