[prev] 35 [next]

Exercise 4: Bit Manipulation

  1. Write a function to display uint32 values as 01010110...

    char *showBits(uint32 val, char *buf);
    

    Analogous to gets()   (assumes supplied buffer large enough)


  2. Write a function to extract the d bits of a uint32

    uint32 bits(int d, uint32 val);
    

    If d > 0, gives low-order bits; if d < 0, gives high-order bits