Nybbles

This is a discussion on Nybbles within the C++ Programming forums, part of the General Programming Boards category; How do I separate the high and low nybbles in a 8 bit binary number?...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    5

    Question Nybbles

    How do I separate the high and low nybbles in a 8 bit binary number?

  2. #2
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    For the low one, you just need to and it
    with 0x0f. For the high one you just need to
    and it with 0xf0 and then shift it to the right by 4.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    FYI, the code for what Nick said is:

    lowNybb = byte & 0x0F;
    highNibb = (byte & 0xF0) >> 4;

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21