Home Segments Index Top Previous Next

470: Mainline

You define a status variable using one of the integral data types—one that is large enough to hold all the bits you need to represent state information. Note, however, that you add the keyword unsigned to the variable declaration. Otherwise, C assumes that 1 bit of the chunk of memory dedicated to the variable's value is to indicate whether the stored number is positive or negative:

    *-- No sign bit to be included            
    |         
    |        *-- An integral data type              
    |        |              
    |        |         *-- The name of this variable is status      
    |        |         |      
    |        |         |     *-- All bits are 0 initially 
    |        v         |     | 
    v    ----------    v     v 
unsigned short char status = 0;