General Discussions

Multiples of 8

To check if the number is multiple of 8, the bitwise way is that: first right shift by 3 and then left shift by 3. Multiple of 8 will remain the same as original number after this operation.

Examples:

8:        1000
>> 3 :  0001
<<3  :  1000

24:      11000
>>3  :  00011
<<3  :  11000

9:         1001
>>3 :    0001
<<3 :    1000

Advertisements

One thought on “Multiples of 8

Let me Know What you Think!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s