Like This Site? 
 
RSS Feed Follow Us 

on Twitter! Be Our Fan!

Understanding Bit-wise Operators in Java

Share this post!
 Vote this!

To understand how to use the bit-wise operators, it is necessary to understand what a bit is. A bit is nothing more than digit in the base 2 representation of a number. (Binary) Yeah, that's the cliche 00101001. The digits here are 0 or 1. So a bit can be a 0 or a 1. On or off. Open or closed, etc. In base 10 (Decimal), we have 10 digits starting at 0 and ending with 9. In base 2 (Binary), we have 2 digits starting at 0 and ending with 1. Simple right? Good let's move on...

Ever wonder why we say "base 2" or "base 10"? That's because the 10 or 2 is the base for conversion. Let's take the decimal number 101 (dalmations). That number's value is:
11          0          1
21*10^2  0*10^1  1*10^0  <--- notice the base is 10
31*100   0*10    1*1
4100     0       1
5101
 more...

0 comments:

Post a Comment