[Courses] Re: [C] My Life program...

Julie txjulie at austin.rr.com
Mon Jul 29 08:22:40 EST 2002


Christopher James Lahey wrote:

> On Fri, 2002-07-26 at 13:43, Julie wrote:
> 
>> Cynthia Grossen wrote:
>> 
>>> array[bit/8] &= ~(1<<(bit%8));
>>> 
>>> This line strikes me as really intense. It seems like there's so much going
>>> on here.
>>> My interpretation of the line is:
>>> Do a bitwise AND on the array at position bit/8 with the bitwise complement
>>> of 1 left-shifted bit%8 positions.
>>> Is this a correct interpretation?
>> 
>> Abstractly speaking, it's "turn off the bit" where "array" is being
>> regarded as a bit string stored in an array of 8 bit char's.
>> 
>> For extra credit, if instead of single bits, each object were 3
>> bits wide, and the bit string was stored in 32 bit unsigned
>> integers, how would you turn off object 'n'?
> 
> 
> Are you storing them as 10 objects per integer with 2 bits ignored, or
> with some objects stored across two words?

I didn't say -- pick a way and describe it.

-- Julie.





More information about the Courses mailing list