Hello,
I can?t seem to find a way to do bitwise ops on a
byte, at least using the standard library. In fact,
when the bytes from a string are converted to
integers, they are converted to platform dependent
integers, so one might argue that it is impossible to
do any platform independent bitwise ops in a
straightforward way in ruby. 

The nature of bitwise ops is one that requires a solid
grasp of what it is you?re manipulating. I would argue
that bitwise ops should be removed from fixnum and
bignum. Instead, have a class representing a bit field
of arbitrary size that can be converted back to an
integer or anything else that can be constructed with
a fixed number of bits --especially a byte. 

Perhaps some would argue that adding every conceivable
integer type to standard ruby would make it ugly, and
I would tend to agree, but I think the byte deserves
special consideration. Ruby strings are 8 bit clean
which is such a beautiful thing, and ruby docs state
that strings can hold arbitrary data, but how would
you get the data from a string if every byte is
converted to a native integer? There doesn?t seem to
be an ?unpack? function that returns an array of
bytes. 

Maybe just add bitwise ops to strings? That way, you
don?t even need a byte datatype, so long as there is a
way to unpack a string into an array of strings where
each string is 1 byte, and that this is not
complicated by any future attempts to turn a string
into a sequence of UTF-8 characters or some such
thing. 

As a side note, I find a lot of the unpack functions
to be just weird. I don?t understand what ?B? and ?b?
are good for. They extract bits but return an array
with 1 element that is a string containing the
characters ?1? and ?0?, but those are not really bits,
and are not useful for bitwise operations. 

I love the design of ruby. Please don?t make me have
to use C or Java just because I want to do some
bitwise ops. It?s just a harmless codec I?m working on
:-)   Actually I already did it in Java :-(

Bernard


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com