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:

    He had been eight years upon a project for extracting sunbeams out of cucumbers, which were to be put into vials hermetically sealed, and let out to warm the air in raw, inclement summers.
    Jonathan Swift (1667–1745)

    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)