On Nov 17, 2007, at 5:28 AM, Jim Guo wrote:
>
> I don't know how to operate on bits and read the integer out.
>
The basics are simple: use #bitAnd: to mask out the bits of interest
and then #bitShift: these to normalize the resulting value.
Unfortunately this leads to rather dense (unreadable) code. So if you
have to maintain a lot of these decoding methods you may be better
off by implementing a bitstream first, then you can write more
readable code like
year := bits next: 11.
See also
http://en.wikipedia.org/wiki/Mask_%28computing%29HTH,
Reinout
-------