Bit shifting limitations

John Meacham john at repetae.net
Sun Jul 13 20:18:15 UTC 2014


On Sun, Jul 13, 2014 at 12:47 PM, David Feuer <david.feuer at gmail.com> wrote:
> ShiftRArithmetic x c = if (isSigned x)
>                                       then shiftR x c
>                                       else (-1 `shiftR` c) .|. (x `shiftR`
> c)


hmm... that isn't quite it because it will always add in the ones on
the left when you only want to do it when the high bit is set, plus it
assumes a specific representation for -1.

   John

-- 
John Meacham - http://notanumber.net/


More information about the Libraries mailing list