chickadee » srfi-60 » rotate-bit-field

rotate-bit-field n count start endprocedure

Returns n with the bit-field from start to end cyclically permuted by count bits towards high-order.

Example:

(number->string (rotate-bit-field #b0100 3 0 4) 2)
   ; => "10"
(number->string (rotate-bit-field #b0100 -1 0 4) 2)
   ; => "10"
(number->string (rotate-bit-field #b110100100010000 -1 5 9) 2)
   ; => "110100010010000"
(number->string (rotate-bit-field #b110100100010000 1 5 9) 2)
   ; => "110100000110000"