Monday, April 25, 2016

Binary Numbers Representation

Binary Numbers

Representation

Binary numbers and arithmetic let you represent any amount you want using just two digits: 0 and 1. Here are some examples:
Decimal 1 is binary 0001
Decimal 3 is binary 0011
Decimal 6 is binary 0110
Decimal 9 is binary 1001

Each digit "1" in a binary number represents a power of two, and each "0" represents zero:
0001 is 2 to the zero power, or 1
0010 is 2 to the 1st power, or 2
0100 is 2 to the 2nd power, or 4
1000 is 2 to the 3rd power, or 8.
When you see a number like "0101" you can figure out what it means by adding the powers of 2:
0101 = 0 + 4 + 0 + 1 = 5
1010 = 8 + 0 + 2 + 0 = 10
0111 = 0 + 4 + 2 + 1 = 7
Addition

Adding two binary numbers together is like adding decimal numbers, except 1 + 1 = 10 (in binary, that is), so you have to carry the one to the next column:
  0001
+ 0100
  ----
  0101 (no carries to get this)
  0001
+ 0001
  ----
  0010 (1 plus 1 is 10, carry the 1 to the next column)
  0011
+ 0011
  ----
  0110 (1 + 1 = 10, so carry; then 1 + 1 + 1 = 11, so carry again)
  0011
+ 0101
  ----
  1000 (carry in every column here)
Subtraction is harder. Don't worry about it.
Larger Numbers

Here are the numbers from 0 to 15, in binary:
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15
To represent bigger whole numbers (integers), you need more bits -- more places in the binary number:
10000101 = 128 + 0 + 0 + 0 + 0 + 4 + 0 + 1 = 133.
That was 8 bits:
8 bits is usually called a "byte", and it's the size usually used to represent an alphabetic character -- "A" is 65, or 01000001
a "nybble" (a term seldom used) is 4 bits;
a "word" depends on the computer but is often 16 or 32 bits.

Some other terms you'll hear are:
kilobyte, which is 1024 bytes (1024 is 2 to the 10th power)
megabyte, which is roughly a million bytes.
Typical sizes for personal computer RAM (random access memory) are 4 to 16 megabytes, while hard disks now start around 150 megabytes. Since each byte can represent one character of the alphabet, that means a hard disk might hold something like 150 million characters, or 25 million words of "raw" text. Documents formatted in a word processor take up a lot more space, though, and the operating system and software usually fill at least 100 megabytes.
To represent real numbers, fractions, or very large numbers, binary systems use "floating point arithmetic." That's another topic.
Why Use 'Em?

For computers, binary numbers are great stuff because:
They are simple to work with -- no big addition tables and multiplication tables to learn, just do the same things over and over, very fast.
They just use two values of voltage, magnetism, or other signal, which makes the hardware easier to design and more noise resistant.

source:- http://binary-net.blogspot.com/

No comments:

Post a Comment