How to get the rightmost four bits from a byte I have a byte that I am looking to break into 2 nibbles. The leftmost nibble I can get easily via shifting right 4 times. However, I can't figure out how to get the rightmost nibble. Any ideas?
Just mask it with an AND operator:

val = var &amp; 0xF;