From: Bernard Miller Date: 2003-01-02T17:24:47+09:00 Subject: Re: How to do bitwise ops on a byte? --- Dossy wrote: > b = 123 # which we know is 01111011 > > # if we want to test for bit 4, we bitwise-and with > 0x08 and > # test to make sure it doesn't equal 0: > if b & 0x08 != 0 > puts "b > end This works for simple bit masking operations, but I�m shifting bits a lot. I need to know the total number of bits I�m dealing with, not just the number of bits that can be assumed from the size of the number. I also need to know the exact order of bits, not just an order relative to the most significant bit which is all you really know when dealing with values instead of bit patterns. The bitvector interface is probably overkill for what I want to do, and I seem to need to know perl to understand the documentation, but I�ll look into it and post a comparison when I�m finished. Thanks for the replies. Bernard __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com