From 71edd798af2d6c5175326045e8218e15eb8f659e Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Wed, 13 Jan 2021 20:11:47 +0900 Subject: [PATCH] Fix bug of 'within' --- bootstrap.fs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bootstrap.fs b/bootstrap.fs index 8061f72..7cea43d 100644 --- a/bootstrap.fs +++ b/bootstrap.fs @@ -659,8 +659,11 @@ allot-cell : &find! [ ' L , , ] ; \ ( c-addr -- nt ) Throw exception at error : 0<= 0 <= ; : 0>= 0 >= ; -\ ( a b c -- (a<=c & c -rot <= and ; +\ ( x a b -- f ) +\ Returns a <= x & x < b if a <= b. +\ It is equivalent to x-a u< b-a. See chapter 4 of +\ Hacker's delight. +: within over - >r - r> u< ; \ arithmetic shift : 2* 1 lshift ; @@ -1099,8 +1102,8 @@ decimal \ set default to decimal endcase 2dup \ ( base n base n ) - 0 -rot - \ ( base n 0 base n ) + swap 0 swap + \ ( base n n 0 base ) within unless \ failed to convert 2drop r> r> nip false