Documente Academic
Documente Profesional
Documente Cultură
In this section we will explain what binary is and show you how to convert between binary and decimal (denary) numbers.
We will also show you how to perform various mathematical operations on binary numbers, including multiplication and division.
Electronically binary numbers are stored/processed using off or on electrical pulses, a digital system will interpret these off and on states as 0 and 1. In other words if the voltage is low then it would represent 0 (off state), and if the voltage is high
then it would represent a 1 (on state).
Binary is Base 2, unlike our counting system decimal which is Base 10 (denary).
In other words, Binary has only 2 different numerals (0 and 1) to denote a value, unlike Decimalwhich has 10 numerals (0,1,2,3,4,5,6,7,8 and 9).
As you can see it is simply a bunch of zeroes and ones, there are 8 numerals in all which make this an 8 bit binary number. Bit is short for Binary Digit, and each numeral is classed as a bit.
The bit on the far right, in this case a 0, is known as the Least significant bit (LSB).
The bit on the far left, in this case a 1, is known as the Most significant bit (MSB)
When writing binary numbers you will need to signify that the number is binary (base 2), as an example let's take the value 101. As it is written, it would be hard to work out whether it is a binary or decimal (denary) value. To get around this
problem it is common to denote the base to which the number belongs by writing the base value with the number, for example:
Once we know the base then it is easy to work out the value, for example:
One other thing about binary numbers is that it is common to signify a negative binary value by placing a 1 (one) at the left hand side (most significant bit) of the value. This is called a sign bit, we will discuss this in more detail below.
Say we want to convert the 8 bit value 10011101 into a decimal value, we can use a formula table like that below:
128 64 32 16 8 4 2 1
1 0 0 1 1 1 0 1
As you can see, we have placed the numbers 1, 2, 4, 8, 16, 32, 64, 128 (powers of two) in reverse numerical order, and then written the binary value below.
To convert, you simply take a value from the top row wherever there is a 1 below and then add the values together.
For a 16 bit value you would use the decimal values 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 (powers of two) for the conversion.
Because we know binary is base 2 then the above could be written as:
Next, write down the value of the remainders from bottom to top (in other words write down the bottom remainder first and work your way up the list) which gives:
10011101 = 157
1 + 1 = 0 (carry one)
1 + 1 (+ the carry) = 1 (carry one)
0 + 1 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)
0 + 1 (+ the carry) = 0 (carry one)
1 + 0 (+ the carry) = 0 (carry one)
The last carry is placed at the left hand side of the result giving: 10000010
By applying these steps you are effectively turning the value into a negative number, and as when dealing with decimal numbers, if you add a negative number to a positive number then you are effectively subtracting to the same value.
note: When subtracting binary values it is important to maintain the same amount of digits for each number, even if it means placing zeroes to the left of the value to make up the digits. For instance, in our example we have added a zero to the
left of the value 1100110 to make the amount of numerals up to 8 (one byte) 01100110.
Now we need to add 11101011 + 10011010, however when you do the addition you always disregard the last carry, so our example would be:
which gives us 10000101, now we can convert this value into decimal, which gives 13310
If you want to subtract a larger number from a smaller number (giving a negative result), then the process is slightly different.
Usually, to indicate a negative number, the most significant bit (left hand bit) is set to 1 and the remaining 7 digits are used to express the value. In this format the MSB is referred to as the sign bit.
Here are the steps for subtracting a large number from a smaller one (negative result).
For example let's do the following subtraction 10010101 - 10110100 (14910 - 18010)
Using the long multiplication method, ie, by multiplying each digit in turn and then adding the values together.
For example, lets do the following multiplication: 1011 x 111 (decimal 1110 x 710)
which gives us 1001101, now we can convert this value into decimal, which gives 7710
note: Notice the pattern in the partial products, as you can see multiplying a binary value by two can be achieved by shifting the bits to the left and adding zeroes to the right.
For example, lets do the following division: 1001 ÷ 11 (decimal 910 ÷ 310)
which gives us 0011, now we can convert this value into decimal, which gives 310
DecimalNumber=nthbit×2n−1DecimalNumber=nthbit×2n−1
Binary to Decimal Formula:
n=bnqn+bn−1qn−2+…..+b2q2+b1q1+b0q0+b−1q−1+b−2q−2n=bnqn+bn−1qn−2+…..+b2q2+b1q1+b0q0+b−1q−1+b−2q−2
Where, N is decimal equivalent,
b is the digit,
q is the base value that starts from most significant digit order qn to least significant order q-1, q-2, …..
To convert binary to decimal the following chart is used and binary is noted as per the given decimal number.
Binary 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
So, for instance, if you use a binary number string it should add the subscript “2” to denote a base 2 number so the binary n umber would be written as 102102. Likewise if it was a standard decimal number it would add the subscript “10” to denote a base 10 and written as 10101010.
To convert binary into decimal is very simple and can be done as shown below:
Say we want to convert the 8 bit value 10011101 into a decimal value, we can use a formula table like that below:
128 64 32 16 8 4 2 1
1 0 0 1 1 1 0 1
To convert, you simply take a value from the top row wherever there is a 1 below and then add the values together.
SOLVED EXAMPLES
Question 1: Convert 0110101 to decimal
Solution:
Given Binary number is 0110101
0110101 = (0 ×× 2626) + (1 ×× 2525) + (1 ×× 2424) + (0 ×× 2323) + (1 ×× 2222) + (0 ×× 2121) + (0 ×× 2020)
= 0 + 32 + 16 + 0 + 4 + 0 + 0
= 52
Answer: Binary Number 0110101 = 52 Decimal number
DECIMAL TO BINARY FORMULA
Decimal to binary conversion is a long process which is usually done by dividing the decimal number to 2. Continuous division of integers is carried out until the reminder reaches to 0 or 1. Note down all the reminders in reverse order and arrive at a binary number corresponding that is almost near to given decimal number.
Here are few decimal numbers and their corresponding binary numbers –
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
SOLVED EXAMPLES
Question 1: Convert 25 in to binary system?
Solution: