Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 4 - Huffman Trees (Part 1)
Date: Thu Oct 4 2001 10:07 am
Author: Detwiler, Jay T. <jtdetwiler@cmu.edu>
Subject: Re: masks

Since I wrote this code....


private int[] masks = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};


Generally, a mask is a constant value that's used in bit manipulation to get a portion of bits from a value. If you have an 8-bit value and want only the value of the first two bits, you AND it with a mask of the bits 00000011.

These masks are single bits used to get at each bit position in a byte. You can see in the code that the operation & is used on a value with each mask. & is the bitwise AND operator.

By the way it's declared, I'm guessing you mean 0x08. The 0x prefix specifies that the value is in hexadecimal encoding, just a convenient way for specifying byte values. 0x08 would be the bits 00000100 or the single bit for the 3rd position.
Post response

Go to the previous messageGo to the following message
Current Thread Detail:
masks      Loving, Benjamin Jameson      Thu Oct 4 2001 12:43 am       
Re: masks      Detwiler, Jay T.      Thu Oct 4 2001 10:07 am       
Re: masks and www.comprenica.com...      Chen, Richard      Wed Oct 24 2001 4:10 am       

Back to previous screen