diff options
Diffstat (limited to 'module/rnrs')
-rw-r--r-- | module/rnrs/arithmetic/bitwise.scm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/module/rnrs/arithmetic/bitwise.scm b/module/rnrs/arithmetic/bitwise.scm index bb3a20797..ac870ff79 100644 --- a/module/rnrs/arithmetic/bitwise.scm +++ b/module/rnrs/arithmetic/bitwise.scm @@ -53,9 +53,13 @@ (logand bitwise-and) (logior bitwise-ior) (logxor bitwise-xor) - (logcount bitwise-bit-count) (ash bitwise-arithmetic-shift))) + (define (bitwise-bit-count ei) + (if (negative? ei) + (bitwise-not (logcount ei)) + (logcount ei))) + (define (bitwise-if ei1 ei2 ei3) (bitwise-ior (bitwise-and ei1 ei2) (bitwise-and (bitwise-not ei1) ei3))) |