From 5ddba1b4e20af37003a87a91dca341af9ce91b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 21 Nov 2021 16:12:24 +0100 Subject: [PATCH] implement WITHIN --- src/fh_builtins_arith.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fh_builtins_arith.c b/src/fh_builtins_arith.c index c068ef5..8660780 100644 --- a/src/fh_builtins_arith.c +++ b/src/fh_builtins_arith.c @@ -205,7 +205,11 @@ static enum fh_error w_within(struct fh_thread_s *fh, const struct fh_word_s *w) // (t-l) (h-l) | U< // =within - bool within = 0; // TODO + const int32_t ti = (int32_t)test; + const int32_t li = (int32_t)low; + const int32_t hi = (int32_t)high; + + const bool within = (uint32_t)(ti-li) < (uint32_t)(hi-li); TRY(ds_push(fh, TOBOOL(within))); return FH_OK; @@ -517,7 +521,7 @@ static enum fh_error w_um_mod(struct fh_thread_s *fh, const struct fh_word_s *w) TRY(ds_pop(fh, &div)); TRY(ds_pop_dw(fh, &num)); - uint64_t res = num / (uint64_t)div; // TODO verify this may be wrong + uint64_t res = num / (uint64_t)div; uint64_t rem = num % (uint64_t)div; if ((uint64_t)(uint32_t)rem != rem) {