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 philosophers stone.”
—Anton Pavlovich Chekhov (18601904)
“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)