Added bitwise-bit-field.
This commit is contained in:
parent
eedbe65e44
commit
9edb15a0f9
|
@ -398,7 +398,7 @@
|
|||
bitwise-arithmetic-shift-right bitwise-arithmetic-shift-left
|
||||
bitwise-arithmetic-shift
|
||||
bitwise-length
|
||||
bitwise-copy-bit
|
||||
bitwise-copy-bit bitwise-bit-field
|
||||
positive? negative? expt gcd lcm numerator denominator
|
||||
exact-integer-sqrt
|
||||
quotient+remainder number->string string->number min max
|
||||
|
@ -421,7 +421,7 @@
|
|||
bitwise-arithmetic-shift-right bitwise-arithmetic-shift-left
|
||||
bitwise-arithmetic-shift
|
||||
bitwise-length
|
||||
bitwise-copy-bit
|
||||
bitwise-copy-bit bitwise-bit-field
|
||||
positive? negative? bitwise-and bitwise-not
|
||||
string->number expt gcd lcm numerator denominator
|
||||
exact->inexact inexact floor ceiling round log
|
||||
|
@ -2470,6 +2470,30 @@
|
|||
(die who "negative bit index" idx))]
|
||||
[else (die who "index is not an exact integer" idx)]))
|
||||
|
||||
(define (bitwise-bit-field n idx1 idx2)
|
||||
(define who 'bitwise-bit-field)
|
||||
(cond
|
||||
[(and (fixnum? idx1) (fx>= idx1 0))
|
||||
(cond
|
||||
[(and (fixnum? idx2) (fx>= idx2 0))
|
||||
(cond
|
||||
[(fx<= idx1 idx2)
|
||||
(cond
|
||||
[(or (fixnum? n) (bignum? n))
|
||||
(bitwise-and
|
||||
(sra n idx1)
|
||||
(- (sll 1 (- idx2 idx1)) 1))]
|
||||
[else (die who "not an exact integer" n)])]
|
||||
[else (die who "invalid order for indices" idx1 idx2)])]
|
||||
[else
|
||||
(if (not (fixnum? idx2))
|
||||
(die who "invalid index" idx2)
|
||||
(die who "negative index" idx2))])]
|
||||
[else
|
||||
(if (not (fixnum? idx1))
|
||||
(die who "invalid index" idx1)
|
||||
(die who "negative index" idx1))]))
|
||||
|
||||
)
|
||||
|
||||
(library (ikarus complexnums)
|
||||
|
|
|
@ -1 +1 @@
|
|||
1355
|
||||
1356
|
||||
|
|
|
@ -762,7 +762,7 @@
|
|||
[bitwise-ior r bw]
|
||||
[bitwise-xor r bw]
|
||||
[bitwise-bit-count i r bw]
|
||||
[bitwise-bit-field r bw]
|
||||
[bitwise-bit-field i r bw]
|
||||
[bitwise-bit-set? i r bw]
|
||||
[bitwise-copy-bit i r bw]
|
||||
[bitwise-copy-bit-field r bw]
|
||||
|
|
|
@ -259,7 +259,7 @@
|
|||
[bitwise-ior S bw]
|
||||
[bitwise-xor S bw]
|
||||
[bitwise-bit-count C bw]
|
||||
[bitwise-bit-field S bw]
|
||||
[bitwise-bit-field C bw]
|
||||
[bitwise-bit-set? C bw]
|
||||
[bitwise-copy-bit C bw]
|
||||
[bitwise-copy-bit-field S bw]
|
||||
|
|
Loading…
Reference in New Issue