;; from Racket reference 4.2.2.6
(define (bitwise-bit-field* n start end)
   (bitwise-and (sub1 (arithmetic-shift 1 (- end start)))
                           (arithmetic-shift n (- start))))

> (bitwise-bit-field #b11111111111111111111111111100010 0 31)
-30
> (bitwise-bit-field* #b11111111111111111111111111100010 0 31)
2147483618 Racket 6.0.1, Windows XP x86

-- 
Roman Klochkov
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to