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 (16671745)
“Living, just by itselfwhat a dirge that is! Life is a classroom and Boredoms the usher, there all the time to spy on you; whatever happens, youve got to look as if you were awfully busy all the time doing something thats terribly excitingor hell come along and nibble your brain.”
—Louis-Ferdinand Céline (18941961)