Nibble - Extracting A Nibble From A Byte

Extracting A Nibble From A Byte

In C programming language:

#define HI_NIBBLE(b) (((b) >> 4) & 0x0F) #define LO_NIBBLE(b) ((b) & 0x0F)

where b must be a variable or constant of an integral data type. (Of course, if b is more than a byte wide, only one of the bytes will be considered).

For example, HI_NIBBLE(0xAB)==0xA and LO_NIBBLE(0xAB)==0xB.

In Common Lisp:

(defun hi-nibble (b) (ldb (byte 4 4) b)) (defun lo-nibble (b) (ldb (byte 4 0) b))

Read more about this topic:  Nibble

Famous quotes containing the words extracting and/or nibble:

    Watching a woman make Russian pancakes, you might think that she was calling on the spirits or extracting from the batter the philosopher’s stone.
    Anton Pavlovich Chekhov (1860–1904)

    Living, just by itself—what a dirge that is! Life is a classroom and Boredom’s the usher, there all the time to spy on you; whatever happens, you’ve got to look as if you were awfully busy all the time doing something that’s terribly exciting—or he’ll come along and nibble your brain.
    Louis-Ferdinand Céline (1894–1961)