Skip to content

Commit

Permalink
Add procedures binary64-normalized-fraction and binary64-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 745e647 commit 38847b7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 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.284.so` and executable `meevax`.
| `all` | Build shared-library `libmeevax.0.5.285.so` and executable `meevax`.
| `install` | Copy files into `/usr/local` directly.
| `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`.
| `package` | Generate debian package `meevax_0.5.285_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.285_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.284
0.5.285
15 changes: 11 additions & 4 deletions basis/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
binary64-epsilon
binary64-exponent
binary64-fractional-part
binary64-integer-exponent
binary64-integer-log-binary
binary64-integral-part
binary64-log-binary
binary64-max
binary64-min
binary64-normalized-fraction
copy-sign
e
euler
Expand Down Expand Up @@ -48,7 +50,8 @@
flonum fladjacent flcopysign make-flonum

flinteger-fraction flexponent flinteger-exponent
; flnormalized-fraction-exponent flsign-bit
flnormalized-fraction-exponent
;flsign-bit
;
; flonum? fl=? fl<? fl>? fl<=? fl>=?
; flunordered? flinteger? flzero? flpositive? flnegative?
Expand Down Expand Up @@ -173,8 +176,12 @@
(values (binary64-integral-part x)
(binary64-fractional-part x)))

(define flexponent binary64-exponent)
(define flexponent binary64-log-binary)

(define flinteger-exponent binary64-integer-exponent)
(define flinteger-exponent binary64-integer-log-binary)

(define (flnormalized-fraction-exponent x)
(values (binary64-normalized-fraction x)
(binary64-exponent x)))
)
)
17 changes: 15 additions & 2 deletions src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,29 @@ namespace meevax::inline kernel
return make(std::modf(car(xs).as<double>(), &integral_part));
});

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

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

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

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

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

library.define<double>("pi", std::numbers::pi);
Expand Down

0 comments on commit 38847b7

Please sign in to comment.