Skip to content

Commit

Permalink
Add procedure flsign-bit
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 38847b7 commit 4cd524e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 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.285.so` and executable `meevax`.
| `all` | Build shared-library `libmeevax.0.5.286.so` and executable `meevax`.
| `install` | Copy files into `/usr/local` directly.
| `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`.
| `package` | Generate debian package `meevax_0.5.286_amd64.deb` (only Ubuntu). The generated package can be installed by `sudo apt install build/meevax_0.5.286_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.285
0.5.286
11 changes: 8 additions & 3 deletions basis/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
binary64-max
binary64-min
binary64-normalized-fraction
binary64-sign-bit
copy-sign
e
euler
Expand All @@ -26,6 +27,7 @@
/
define
expt
if
inexact
values
)
Expand All @@ -50,9 +52,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?
; flodd? fleven? flfinite? flinfinite? flnan?
Expand Down Expand Up @@ -183,5 +184,9 @@
(define (flnormalized-fraction-exponent x)
(values (binary64-normalized-fraction x)
(binary64-exponent x)))

(define (flsign-bit x)
(if (binary64-sign-bit x) 1 0))

)
)
5 changes: 5 additions & 0 deletions src/kernel/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ namespace meevax::inline kernel
return make<exact_integer>(exponent);
});

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

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

library.define<double>("pi", std::numbers::pi);
Expand Down
12 changes: 11 additions & 1 deletion test/srfi-144.ss
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@

(check (flinteger-exponent -48.0) => 5)

(call-with-values
(lambda () (flnormalized-fraction-exponent 48.0))
(lambda (fraction exponent)
(check fraction => 0.75)
(check exponent => 6)))

(check (flsign-bit 3.14) => 0)

(check (flsign-bit -3.14) => 1)

(check-report)

(exit (check-passed? 65))
(exit (check-passed? 69))

0 comments on commit 4cd524e

Please sign in to comment.