on-internet
← Community

Comparing Bitfields of Different Sizes

Stack Overflow ·

What happens if you use a bitwise operator (&, |, etc.) to compare two bitfields of different sizes? For example, comparing 0 1 1 0 with 0 0 1 0 0 0 0 1: 0 1 1 0 0 0 0 0 The smaller one is extended with zeros and pushed to the 0 0 1 0 0 0 0 1 most-significant side. Or... 0 0 0 0 0 1 1 0 The smaller one is extended with zeros and pushed to the 0 0 1 0 0 0 0 1 least-significant side. Or... 0 1 1 0 The longer one is truncated from its least-significant side, 0 0 1 0 keeping its most significant side. Or... 0 1 1 0 The longer one is truncated from its most-significant side, 0 0 0 1 keeping its lea

Comments

Sign in or sign up to comment and upvote.

No comments yet.