Sie sind auf Seite 1von 32

Binary to Decimal Conversion

Binary to Decimal Conversion of numbers uses weighted columns to identify the order of the digits to determine the final
value of the number

Conversion of binary to decimal (base-2 to base-10) numbers and back is an important concept to understand as the binary
numbering system forms the basis for all computer and digital systems.

The decimal or “denary” counting system uses the Base-of-10 numbering system where each digit in a number takes on one of
ten possible values, called “digits”, from 0 to 9, eg. 21310 (Two Hundred and Thirteen).

But as well as having 10 digits ( 0 through 9 ), the decimal numbering system also has the operations of addition ( + ), subtraction
( – ), multiplication ( × ) and division ( ÷ ).

In a decimal system each digit has a value ten times greater than its previous number and this decimal numbering system uses a
set of symbols, b, together with a base, q, to determine the weight of each digit within a number. For example, the six in sixty has
a lower weighting than the six in six hundred. Then in a binary numbering system we need some way of converting Decimal to
Binary as well as back from Binary to Decimal.

Any numbering system can be summarised by the following relationship:

N = bi qi

where: N is a real positive number


b is the digit
q is the base value
and integer (i) can be positive, negative or zero

N = bn qn… b3 q3 + b2 q2 + b1 q1 + b0 q0 + b-1 q-1 + b-2 q-2… etc.

The Decimal Numbering System

In the decimal, base-10 (den) or denary numbering system, each integer number column has values of units, tens, hundreds,
thousands, etc as we move along the number from right to left. Mathematically these values are written as 100, 101, 102, 103 etc.
Then each position to the left of the decimal point indicates an increased positive power of 10. Likewise, for fractional numbers
the weight of the number becomes more negative as we move from left to right, 10-1, 10-2, 10-3 etc.

So we can see that the “decimal numbering system” has a base of 10 or modulo-10(sometimes called MOD-10) with the position
of each digit in the decimal system indicating the magnitude or weight of that digit as q is equal to “10” (0 through 9). For
example, 20 (twenty) is the same as saying 2 x 101 and therefore 400 (four hundred) is the same as saying 4 x 102.

The value of any decimal number will be equal to the sum of its digits multiplied by their respective weights. For
example: N = 616310 (Six Thousand One Hundred and Sixty Three) in a decimal format is equal to:
6000 + 100 + 60 + 3 = 6163
or it can be written reflecting the weight of each digit as:

( 6×1000 ) + ( 1×100 ) + ( 6×10 ) + ( 3×1 ) = 6163


or it can be written in polynomial form as:
( 6×103 ) + ( 1×102 ) + ( 6×101 ) + ( 3×100 ) = 6163

Where in this decimal numbering system example, the left most digit is the most significant digit, or MSD, and the right most digit
is the least significant digit or LSD. In other words, the digit 6 is the MSD since its left most position carries the most weight, and
the number 3 is the LSD as its right most position carries the least weight.

The Binary Numbering System

The Binary Numbering System is the most fundamental numbering system in all digital and computer based systems and binary
numbers follow the same set of rules as the decimal numbering system. But unlike the decimal system which uses powers of ten,
the binary numbering system works on powers of two giving a binary to decimal conversion from base-2 to base-10.

Digital logic and computer systems use just two values or states to represent a condition, a logic level “1” or a logic level “0”, and
each “0” and “1” is considered to be a single digit in a Base-of-2 (bi) or “binary numbering system”.

In the binary numbering system, a binary number such as 101100101 is expressed with a string of “1’s” and “0’s” with each digit
along the string from right to left having a value twice that of the previous digit. But as it is a binary digit it can only have a value
of either “1” or “0” therefore, q is equal to “2” (0 or 1) with its position indicating its weight within the string.

As the decimal number is a weighted number, converting from decimal to binary (base 10 to base 2) will also produce a weighted
binary number with the right-hand most bit being the Least Significant Bit or LSB, and the left-hand most bit being the Most
Significant Bitor MSB, and we can represent this as:

Representation of a Binary Number

MSB Binary Digit LSB

28 27 26 25 24 23 22 21 20

256 128 64 32 16 8 4 2 1

We saw above that in the decimal number system, the weight of each digit from right to left increases by a factor of 10. In the
binary number system, the weight of each digit increases by a factor of 2 as shown. Then the first digit has a weight of 1 ( 20 ),
the second digit has a weight of 2 ( 21 ), the third a weight of 4 ( 22 ), the fourth a weight of 8 ( 23 ) and so on.

So for example, converting a Binary to Decimal number would be:


Decimal Digit Value 256 128 64 32 16 8 4 2 1

Binary Digit Value 1 0 1 1 0 0 1 0 1

By adding together ALL the decimal number values from right to left at the positions that are represented by a “1” gives
us: (256) + (64) + (32) + (4) + (1) = 35710 or three hundred and fifty seven as a decimal number.

Then, we can convert binary to decimal by finding the decimal equivalent of the binary array of digits 1011001012 and expanding
the binary digits into a series with a base of 2giving an equivalent of 35710 in decimal or denary.

Note that in number conversion systems “subscripts” are used to indicate the relevant base numbering system, 10012 = 910. If no
subscript is used after a number, then it is generally assumed to be decimal.

Repeated Division-by-2 Method

We have seen above how to convert binary to decimal numbers, but how do we convert a decimal number into a binary number.
An easy method of converting decimal to binary number equivalents is to write down the decimal number and to continually
divide-by-2 (two) to give a result and a remainder of either a “1” or a “0” until the final result equals zero.

So for example. Convert the decimal number 29410 into its binary number equivalent.

Number 294

divide by 2

Dividing each decimal number by “2” as


result 147 remainder 0 (LSB)
shown will give a result plus a
remainder.
divide by 2
If the decimal number being divided is
even then the result will be whole and
result 73 remainder 1 the remainder will be equal to “0”. If
the decimal number is odd then the
result will not divide completely and the
divide by 2 remainder will be a “1”.
The binary result is obtained by placing
result 36 remainder 1 all the remainders in order with the
least significant bit (LSB) being at the
top and the most significant bit (MSB)
divide by 2 being at the bottom.

result 18 remainder 0

divide by 2
result 9 remainder 0

divide by 2

result 4 remainder 1

divide by 2

result 2 remainder 0

divide by 2

result 1 remainder 0

divide by 2

1 (MSB
result 0 remainder
)

This divide-by-2 decimal to binary conversion technique gives the decimal number 29410an equivalent of 1001001102 in binary,
reading from right to left. This divide-by-2 method will also work for conversion to other number bases.

Then we can see that the main characteristics of a Binary Numbering System is that each “binary digit” or “bit” has a value of
either “1” or “0” with each bit having a weight or value double that of its previous bit starting from the lowest or least significant
bit (LSB) and this is called the “sum-of-weights” method.

So we can convert a decimal number into a binary number either by using the sum-of-weights method or by using the repeated
division-by-2 method, and convert binary to decimal by finding its sum-of-weights.

Binary Number Names & Prefixes

Binary numbers can be added together and subtracted just like decimal numbers with the result being combined into one of
several size ranges depending upon the number of bits being used. Binary numbers come in three basic forms – a bit, a byte and a
word, where a bit is a single binary digit, a byte is eight binary digits, and a word is 16 binary digits.

The classification of individual bits into larger groups are generally referred to by the following more common names of:

Number of Binary Digits (bits) Common Name

1 Bit
4 Nibble

8 Byte

16 Word

32 Double Word

64 Quad Word

Also, when converting from Binary to Decimal or even from Decimal to Binary, we need to be careful that we do not mix up the
two sets of numbers. For example, if we write the digits 10 on the page it could mean the number “ten” if we assume it to be a
decimal number, or it could equally be a “1” and a “0” together in binary, which is equal to the number two in the weighted
decimal format from above.

One way to overcome this problem when converting binary to decimal numbers and to identify whether the digits or numbers
being used are decimal or binary is to write a small number called a “subscript” after the last digit to show the base of the number
system being used.

So for example, if we were using a binary number string we would add the subscript “2” to denote a base-2 number so the
number would be written as 102. Likewise, if it was a standard decimal number we would add the subscript “10” to denote a
base-10 number so the number would be written as 1010.

Today, as micro-controller or microprocessor systems become increasingly larger, the individual binary digits (bits) are now
grouped together into 8’s to form a single BYTE with most computer hardware such as hard drives and memory modules
commonly indicate their size in Megabytes or even Gigabytes.

Number of Bytes Common Name

1,024 (210) kilobyte (kb)

1,048,576 (220) Megabyte (Mb)

1,073,741,824 (230) Gigabyte (Gb)

a very long number! (240) Terabyte (Tb)

Binary to Decimal Summary

 A “BIT” is the abbreviated term derived from BInary digiT


 A Binary system has only two states, Logic “0” and Logic “1” giving a base of 2
 A Decimal system uses 10 different digits, 0 to 9 giving it a base of 10
 A Binary number is a weighted number who’s weighted value increases from right to left
 The weight of a binary digit doubles from right to left
 A decimal number can be converted to a binary number by using the sum-of-weights method or the repeated
division-by-2 method
 When we convert numbers from binary to decimal, or decimal to binary, subscripts are used to avoid errors

Converting binary to decimal (base-2 to base-10) or decimal to binary numbers (base10 to base-2) can be done in a number of
different ways as shown above. When converting decimal numbers to binary numbers it is important to remember which is the
least significant bit (LSB), and which is the most significant bit (MSB).

In the next tutorial about Binary Logic> we will look at converting binary numbers into Hexadecimal Numbers and vice versa and
show that binary numbers can be represented by letters as well as numbers.

Hexadecimal Numbers

Hexadecimal Numbers group binary numbers into sets of four allowing for the conversion of 16 different binary digits

The one main disadvantage of binary numbers is that the binary string equivalent of a large decimal base-10 number can be quite
long.

When working with large digital systems, such as computers, it is common to find binary numbers consisting of 8, 16 and even 32
digits which makes it difficult to both read or write without producing errors especially when working with lots of 16 or 32-bit
binary numbers.

One common way of overcoming this problem is to arrange the binary numbers into groups or sets of four bits (4-bits). These
groups of 4-bits uses another type of numbering system also commonly used in computer and digital systems called Hexadecimal
Numbers.

Hexadecimal Number String

The “Hexadecimal” or simply “Hex” numbering system uses the Base of 16 system and are a popular choice for representing long
binary values because their format is quite compact and much easier to understand compared to the long binary strings of 1’s
and 0’s.

Being a Base-16 system, the hexadecimal numbering system therefore uses 16 (sixteen) different digits with a combination of
numbers from 0 through to 15. In other words, there are 16 possible digit symbols.
However, there is a potential problem with using this method of digit notation caused by the fact that the decimal numerals of 10,
11, 12, 13, 14 and 15 are normally written using two adjacent symbols. For example, if we write 10 in hexadecimal, do we mean
the decimal number ten, or the binary number of two (1 + 0). To get around this tricky problem hexadecimal numbers that
identify the values of ten, eleven, . . . , fifteen are replaced with capital letters of A, B, C, D, E and F respectively.

Then in the Hexadecimal Numbering System we use the numbers from 0 to 9 and the capital letters A to F to represent its Binary
or Decimal number equivalent, starting with the least significant digit at the right hand side.

As we have just said, binary strings can be quite long and difficult to read, but we can make life easier by splitting these large
binary numbers up into even groups to make them much easier to write down and understand. For example, the following group
of binary digits 1101 0101 1100 11112 are much easier to read and understand than11010101110011112 when they are all
bunched up together.

In the everyday use of the decimal numbering system we use groups of three digits or 000’s from the right hand side to make a
very large number such as a million or trillion, easier for us to understand and the same is also true in digital systems.

Hexadecimal Numbers is a more complex system than using just binary or decimal and is mainly used when dealing with
computers and memory address locations. By dividing a binary number up into groups of 4 bits, each group or set of 4 digits can
now have a possible value of between “0000” (0) and “1111” ( 8+4+2+1 = 15 ) giving a total of 16different number combinations
from 0 to 15. Don’t forget that “0” is also a valid digit.

We remember from our first tutorial about Binary Numbers that a 4-bit group of digits is called a “nibble” and as 4-bits are also
required to produce a hexadecimal number, a hex digit can also be thought of as a nibble, or half-a-byte. Then two hexadecimal
numbers are required to produce one full byte ranging from 00 to FF.

Also, since 16 in the decimal system is the fourth power of 2 ( or 24 ), there is a direct relationship between the
numbers 2 and 16 so one hex digit has a value equal to four binary digits so now q is equal to “16”.

Because of this relationship, four digits in a binary number can be represented with a single hexadecimal digit. This makes
conversion between binary and hexadecimal numbers very easy, and hexadecimal can be used to write large binary numbers with
much fewer digits.

The numbers 0 to 9 are still used as in the original decimal system, but the numbers from 10 to 15 are now represented by capital
letters of the alphabet from A to F inclusive and the relationship between decimal, binary and hexadecimal is given below.

Hexadecimal Numbers

Decimal Number 4-bit Binary Number Hexadecimal Number

0 0000 0

1 0001 1

2 0010 2
3 0011 3

4 0100 4

5 0101 5

6 0110 6

7 0111 7

8 1000 8

9 1001 9

10 1010 A

11 1011 B

12 1100 C

13 1101 D

14 1110 E

15 1111 F

16 0001 0000 10 (1+0)

17 0001 0001 11 (1+1)

Continuing upwards in groups of four

Using the original binary number from above 1101 0101 1100 11112 this can now be converted into an equivalent hexadecimal
number of D5CF which is much easier to read and understand than a long row of 1’s and 0’s that we had before.

So by using hexadecimal notation, digital numbers can be written using fewer digits and with a much less likelihood of an error
occurring. Similarly, converting hexadecimal based numbers back into binary is simply the reverse operation.

Then the main characteristics of a Hexadecimal Numbering System is that there are 16 distinct counting digits from 0 to F with
each digit having a weight or value of 16 starting from the least significant bit (LSB). In order to distinguish Hexadecimal numbers
from Denary numbers, a prefix of either a “#”, (Hash) or a “$” (Dollar sign) is used before the actual Hexadecimal
Number value, #D5CF or $D5CF.
As the base of a hexadecimal system is 16, which also represents the number of individual symbols used in the system, the
subscript 16 is used to identify a number expressed in hexadecimal. For example, the previous hexadecimal number is expressed
as: D5CF16

Counting using Hexadecimal Numbers

So we now know how to convert 4 binary digits into a hexadecimal number. But what if we had more than 4 binary digits how
would we count in hexadecimal beyond the final letter F. The simple answer is to start over again with another set of 4 bits as
follows.

0…to…9, A,B,C,D,E,F, 10…to…19, 1A, 1B, 1C, 1D, 1E, 1F, 20, 21….etc

Do not get confused, 10 or 20 is NOT ten or twenty it is 1 + 0 and 2 + 0 in hexadecimal. In fact twenty does not even exist in hex.
With two hexadecimal numbers we can count up to FF which is equal to decimal 255. Likewise, to count higher than FF we would
add a third hexadecimal digit to the left so the first 3-bit hexadecimal number would be 10016,(25610) and the last would
be FFF16, (409510). The maximum 4-digit hexadecimal number is FFFF16 which is equal to 65,535 in decimal and so on.

Representation of a Hexadecimal Number

MSB Hexadecimal Number LSB

168 167 166 165 164 163 162 161 160

4.3G 2.6G 16M 1M 65k 4k 256 16 1

This adding of additional hexadecimal digits to convert both decimal and binary numbers into an Hexadecimal Number is very
easy if there are 4, 8, 12 or 16 binary digits to convert. But we can also add zero’s to the left of the most significant bit, the MSB if
the number of binary bits is not a multiple of four.

For example, 110010110110012 is a fourteen bit binary number that is to large for just three hexadecimal digits only, yet too
small for a four hexadecimal number. The answer is to ADD additional zero’s to the left most bit until we have a complete set of
four bit binary number or multiples thereof.

Adding of Additional 0’s to a Binary Number

Binary Number 0011 0010 1101 1001

Hexadecimal Number 3 2 D 9
The main advantage of a Hexadecimal Number is that it is very compact and by using a base of 16 means that the number of
digits used to represent a given number is usually less than in binary or decimal. Also, it is quick and easy to convert between
hexadecimal numbers and binary.

Hexadecimal Numbers Example No1

Convert the following Binary number 1110 10102 into its Hexadecimal number equivalent.

Binary Number = 111010102

Group the bits into four’s starting from the right hand side

= 1110 1010

Find the Decimal equivalent of each individual group

= 14 10 (in decimal)

Convert to Hexadecimal using the table above

= E A (in Hex)

Then, the hexadecimal equivalent of the binary number


1110 10102 is #EA16

Hexadecimal Numbers Example No2

Convert the following Hexadecimal number #3FA716 into its Binary equivalent, and also into its Decimal or Denary equivalent
using subscripts to identify each numbering system.

#3FA716

= 0011 1111 1010 01112

= (8192 + 4096 + 2048 + 1024 + 512 + 256 + 128 + 32 + 4 + 2 + 1)

= 16,29510

Then, the Decimal number of 16,295 can be represented as:-


#3FA716 in Hexadecimal
or

0011 1111 1010 01112 in Binary.

Hexadecimal Numbers Summary

Then to summarise. The Hexadecimal, or Hex, numbering system is commonly used in computer and digital systems to reduce
large strings of binary numbers into a sets of four digits for us to easily understand. The word “Hexadecimal” means sixteen
because this type of digital numbering system uses 16 different digits from 0-to-9, and A-to-F.

To convert binary numbers into hexadecimal numbers we must first divide the binary number up into a 4-bit binary word which
can have any value from 010 ( 00002 ) to 1510 ( 11112 ) representing the hexadecimal equivalent of 0 through to F.

In the next tutorial about Binary Logic we will look at converting strings of binary numbers into another digital numbering system
called Octal Numbers and vice versa.

Octal Number System

The Octal Number System is another type of computer and digital numbering system which uses the Base-8 system

The Octal Numbering System is very similar in principle to the previous hexadecimal numbering system except that in Octal, a
binary number is divided up into groups of only 3 bits, with each group or set of bits having a distinct value of between 000 (0)
and 111 ( 4+2+1 = 7 ).

Octal numbers therefore have a range of just “8” digits, (0, 1, 2, 3, 4, 5, 6, 7) making them a Base-8 numbering system and
therefore, q is equal to “8”.

Then the main characteristics of an Octal Numbering System is that there are only 8 distinct counting digits from 0 to 7 with each
digit having a weight or value of just 8 starting from the least significant bit (LSB). In the earlier days of computing, octal numbers
and the octal numbering system was very popular for counting inputs and outputs because as it works in counts of eight, inputs
and outputs were in counts of eight, a byte at a time.

As the base of an Octal Numbers system is 8 (base-8), which also represents the number of individual numbers used in the
system, the subscript 8 is used to identify a number expressed in octal. For example, an octal number is expressed as: 2378

Just like the hexadecimal system, the “octal number system” provides a convenient way of converting large binary numbers into
more compact and smaller groups. However, these days the octal numbering system is used less frequently than the more
popular hexadecimal numbering system and has almost disappeared as a digital base number system.

Representation of an Octal Number


MSB Octal Number LSB

88 87 86 85 84 83 82 81 80

16M 2M 262k 32k 4k 512 64 8 1

As the octal number system uses only eight digits (0 through 7) there are no numbers or letters used above 8, but the conversion
from decimal to octal and binary to octal follows the same pattern as we have seen previously for hexadecimal.

To count above 7 in octal we need to add another column and start over again in a similar way to hexadecimal.

0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21….etc

Again do not get confused, 10 or 20 is NOT ten or twenty it is 1 + 0 and 2 + 0 in octal exactly the same as for hexadecimal. The
relationship between binary and octal numbers is given below.

Octal Numbers

Decimal Number 3-bit Binary Number Octal Number

0 000 0

1 001 1

2 010 2

3 011 3

4 100 4

5 101 5

6 110 6

7 111 7

8 001 000 10 (1+0)

9 001 001 11 (1+1)


Continuing upwards in groups of three

Then we can see that 1 octal number or digit is equivalent to 3 bits, and with two octal number, 778 we can count up to 63 in
decimal, with three octal numbers, 7778 up to 511 in decimal and with four octal numbers, 77778 up to 4095 in decimal and so
on.

Octal Numbers Example No1

Using our previous binary number of 11010101110011112 convert this binary number to its octal equivalent, (base-2 to base-8).

Binary Digit Value 001101010111001111

Group the bits into three´s starting


001 101 010 111 001 111
from the right hand side

Octal Number form 1 5 2 7 1 78

Thus, 0011010101110011112 in its Binary form is equivalent to 1527178 in Octal form or 54,735 in denary.

Octal Numbers Example No2

Convert the octal number 23228 to its decimal number equivalent, (base-8 to base-10).

Octal Digit
23228
Value

In polynomial
= ( 2×83 ) + ( 3×82 ) + ( 2×81 ) + ( 2×80 )
form

Add the results = ( 1024 ) + ( 192 ) + ( 16 ) + ( 2 )

Decimal number form equals: 123410

Then, converting octal to decimal shows that 23228 in its Octal form is equivalent to 123410 in its Decimal form.

While Octal is another type of digital numbering system, it is little used these days instead the more commonly used Hexadecimal
Numbering System is used as it is more flexible.
Binary Numbers Tutorial

There are different yet similar binary numbering systems used in digital electronic circuits and computers.

However, the numbering system used in one type of circuit may be different to that of another type of circuit, for example, the
memory of a computer would use hexadecimal numbers while the keyboard uses decimal numbers.

Then the conversion from one number system to another is very important with the four main forms of arithmetic being.

 Decimal – The decimal numbering system has a base of 10 (MOD-10) and uses the digits from 0 through 9 to
represent a decimal number value.
 Binary – The binary numbering system has a base of 2 (MOD-2) and uses only two digits a “0” and a “1” to represent a
binary number value.
 Octal – The octal numbering system has a base of 8 (MOD-8) and uses 8 digits between 0 and 7 to represent an octal
number value.
 Hexadecimal – The Hexadecimal numbering system has a base of 16 (MOD-16) and uses a total of 16 numeric and
alphabetic characters to represent a number value. Hexadecimal numbers consist of digits 0 through 9 and letters A to F.

Long binary numbers are difficult to both read or write and are generally converted into a system more easily understood or user
friendly. The two most common derivatives based on binary numbers are the Octal and the Hexadecimal numbering systems,
with both of these limited in length to a byte (8-bits) or a word (16-bits).

Octal numbers can be represented by groups of 3-bits and hexadecimal numbers by groups of 4-bits together, with this grouping
of the bits being used in electronic or computer systems in displays or printouts. The grouping together of binary numbers can
also be used to represent Machine Code used for programming instructions and control such as an Assembly Language.

Comparisons between the various Decimal, Binary, Hexadecimal and Octal numbers are given in the following table.

Digital Numbering System Comparison Table

Base, b Byte (8-bits) Word (16-bits)

0 0
Decimal to to
25510 65,53510

0000 0000 0000 0000 0000 0000


Binary to to
1111 11112 1111 1111 1111 11112

00 0000
Hexadecimal to to
FF16 FFFF16
000 000 000
Octal to to
3778 177 7778

We can see from the table above that the Hexadecimal numbering system uses only four digits to express a single 16-bit word
length, and as a result it is the most commonly used Base Numbering System for digital, micro-electronic and computer systems.

Signed Binary Numbers

Signed Binary Numbers use the MSB as a sign bit to display a range of either positive numbers or negative numbers

In mathematics, positive numbers (including zero) are represented as unsigned numbers. That is we do not put the +ve sign in
front of them to show that they are positive numbers.

However, when dealing with negative numbers we do use a -ve sign in front of the number to show that the number is negative in
value and different from a positive unsigned value, and the same is true with signed binary numbers.

However, in digital circuits there is no provision made to put a plus or even a minus sign to a number, since digital systems
operate with binary numbers that are represented in terms of “0’s” and “1’s”. When used together in microelectronics, these
“1’s” and “0’s”, called a bit (being a contraction of BInary digiT), fall into several range sizes of numbers which are referred to by
common names, such as a byte or a word.

We have also seen previously that an 8-bit binary number (a byte) can have a value ranging from 0 (000000002) to 255
(111111112), that is 28 = 256 different combinations of bits forming a single 8-bit byte. So for example an unsigned binary
number such as: 010011012 = 64 + 8 + 4 + 1 = 7710 in decimal. But Digital Systems and computers must also be able to use and
to manipulate negative numbers as well as positive numbers.

Mathematical numbers are generally made up of a sign and a value (magnitude) in which the sign indicates whether the number
is positive, ( + ) or negative, ( – ) with the value indicating the size of the number, for example 23, +156 or -274. Presenting
numbers is this fashion is called “sign-magnitude” representation since the left most digit can be used to indicate the sign and the
remaining digits the magnitude or value of the number.

Sign-magnitude notation is the simplest and one of the most common methods of representing positive and negative numbers
either side of zero, (0). Thus negative numbers are obtained simply by changing the sign of the corresponding positive number as
each positive or unsigned number will have a signed opposite, for example, +2 and -2, +10 and -10, etc.

But how do we represent signed binary numbers if all we have is a bunch of one’s and zero’s. We know that binary digits, or bits
only have two values, either a “1” or a “0” and conveniently for us, a sign also has only two values, being a “+” or a “–“.

Then we can use a single bit to identify the sign of a signed binary number as being positive or negative in value. So to represent a
positive binary number (+n) and a negative (-n) binary number, we can use them with the addition of a sign.

For signed binary numbers the most significant bit (MSB) is used as the sign bit. If the sign bit is “0”, this means the number is
positive in value. If the sign bit is “1”, then the number is negative in value. The remaining bits in the number are used to
represent the magnitude of the binary number in the usual unsigned binary number format way.
Then we can see that the Sign-and-Magnitude (SM) notation stores positive and negative values by dividing the “n” total bits into
two parts: 1 bit for the sign and n–1 bits for the value which is a pure binary number. For example, the decimal number 53 can be
expressed as an 8-bit signed binary number as follows.

Positive Signed Binary Numbers

Negative Signed Binary Numbers

The disadvantage here is that whereas before we had a full range n-bit unsigned binary number, we now have an n-1 bit signed
binary number giving a reduced range of digits from:

-2(n-1) to +2(n-1)

So for example: if we have 4 bits to represent a signed binary number, (1-bit for the Sign bit and 3-bits for the Magnitude bits),
then the actual range of numbers we can represent in sign-magnitude notation would be:

-2(4-1) – 1 to +2(4-1) – 1
-2(3) – 1 to +2(3) – 1
-7 to +7

Whereas before, the range of an unsigned 4-bit binary number would have been from 0 to 15, or 0 to F in hexadecimal, we now
have a reduced range of -7 to +7. Thus an unsigned binary number does not have a single sign-bit, and therefore can have a larger
binary range as the most significant bit (MSB) is just an extra bit or digit rather than a used sign bit.

Another disadvantage here of the sign-magnitude form is that we can have a positive result for zero, +0 or 00002, and a negative
result for zero, -0 or 10002. Both are valid but which one is correct.

Signed Binary Numbers Example No1

Convert the following decimal values into signed binary numbers using the sign-magnitude format:
-1510 as a 6-bit number ⇒ 1011112

+2310 as a 6-bit number ⇒ 0101112

-5610 as a 8-bit number ⇒ 101110002

+8510 as a 8-bit number ⇒ 010101012

-12710 as a 8-bit number ⇒ 111111112

Note that for a 4-bit, 6-bit, 8-bit, 16-bit or 32-bit signed binary number all the bits MUST have a value, therefore “0’s” are used to
fill the spaces between the leftmost sign bit and the first or highest value “1”.

The sign-magnitude representation of a binary number is a simple method to use and understand for representing signed binary
numbers, as we use this system all the time with normal decimal (base 10) numbers in mathematics. Adding a “1” to the front of
it if the binary number is negative and a “0” if it is positive.

However, using this sign-magnitude method can result in the possibility of two different bit patterns having the same binary value.
For example, +0 and -0 would be 0000 and 1000 respectively as a signed 4-bit binary number. So we can see that using this
method there can be two representations for zero, a positive zero ( 00002 ) and also a negative zero ( 10002 ) which can cause big
complications for computers and digital systems.

One’s Complement of a Signed Binary Number

One’s Complement or 1’s Complement as it is also termed, is another method which we can use to represent negative binary
numbers in a signed binary number system. In one’s complement, positive numbers (also known as non-complements) remain
unchanged as before with the sign-magnitude numbers.

Negative numbers however, are represented by taking the one’s complement (inversion, negation) of the unsigned positive
number. Since positive numbers always start with a “0”, the complement will always start with a “1” to indicate a negative
number.

The one’s complement of a negative binary number is the complement of its positive counterpart, so to take the one’s
complement of a binary number, all we need to do is change each bit in turn. Thus the one’s complement of “1” is “0” and vice
versa, then the one’s complement of 100101002 is simply 011010112 as all the 1’s are changed to 0’s and the 0’s to 1’s.

The easiest way to find the one’s complement of a signed binary number when building digital arithmetic or logic decoder circuits
is to use Inverters. The inverter is naturally a complement generator and can be used in parallel to find the 1’s complement of
any binary number as shown.

1’s Complement Using Inverters


Then we can see that it is very easy to find the one’s complement of a binary number N as all we need do is simply change the 1’s
to 0’s and the 0’s to 1’s to give us a -N equivalent. Also just like the previous sign-magnitude representation, one’s complement
can also have n-bit notation to represent numbers in the range from: -2(n-1) and +2(n-1) – 1. For example, a 4-bit representation
in the one’s complement format can be used to represent decimal numbers in the range from -7 to +7 with two representations
of zero: 0000 (+0) and 1111 (-0) the same as before.

Addition and Subtraction Using One’s Complement

One of the main advantages of One’s Complement is in the addition and subtraction of two binary numbers. In mathematics,
subtraction can be implemented in a variety of different ways as A – B, is the same as saying A + (-B) or -B + A etc. Therefore, the
complication of subtracting two binary numbers can be performed by simply using addition.

We saw in the Binary Adder tutorial that binary addition follows the same rules as for the normal addition except that in binary
there are only two bits (digits) and the largest digit is a “1”, (just as “9” is the largest decimal digit) thus the possible combinations
for binary addition are as follows:

0 0 1 1

+0 +1 +0 +1

0 1 1 1← 0 ( 0 plus a carry 1 )

When the two numbers to be added are both positive, the sum A + B, they can be added together by means of the direct sum
(including the number and bit sign), because when single bits are added together, “0 + 0”, “0 + 1”, or “1 + 0” results in a sum of
“0” or “1”. This is because when the two bits we want to be added together are odd (“0” + “1” or “1 + 0”), the result is “1”.
Likewise when the two bits to be added together are even (“0 + 0” or “1 + 1”) the result is “0” until you get to “1 + 1” then the
sum is equal to “0” plus a carry “1”. Let’s look at a simple example.

Subtraction of Two Binary Numbers

An 8-bit digital system is required to subtract the following two numbers 115 and 27 from each other using one’s complement. So
in decimal this would be: 115 – 27 = 88.

First we need to convert the two decimal numbers into binary and make sure that each number has the same number of bits by
adding leading zero’s to produce an 8-bit number (byte). Therefore:
11510 in binary is: 0 1 1 1 0 0 1 1 2
2710 in binary is: 0 0 0 1 1 0 1 1 2

Now we need to find the complement of the second binary number, (00011011) while leaving the first number (01110011)
unchanged. So by changing all the 1’s to 0’s and 0’s to 1’s, the one’s complement of 00011011 is therefore equal to 11100100.

Adding the first number and the complement of the second number gives:

01110011

+ 11100100

Overflow → 1 01010111

Since the digital system is to work with 8-bits, only the first eight digits are used to provide the answer to the sum, and we simply
ignore the last bit (bit 9). This bit is call an “overflow” bit. Overflow occurs when the sum of the most significant (left-most)
column produces a carry forward. This overflow or carry bit can be ignored completely or passed to the next digital section for use
in its calculations. Overflow indicates that the answer is positive. If there is no overflow then the answer is negative.

The 8-bit result from above is: 01010111 (the overflow “1” cancels out) and to convert it back from a one’s complement answer
to the real answer we now have to add “1” to the one’s complement result, therefore:

01010111

+ 1

01011000

So the result of subtracting 27 ( 000110112 ) from 115 ( 011100112 ) using 1’s complement in binary gives the answer
of: 010110002 or (64 + 16 + 8) = 8810 in decimal.

Then we can see that signed or unsigned binary numbers can be subtracted from each other using One’s Complement and the
process of addition. Binary adders such as the TTL 74LS83 or 74LS283 can be used to add or subtract two 4-bit signed binary
numbers or cascaded together to produce 8-bit adders complete with carry-out.

Two’s Complement of a Signed Binary Number

Two’s Complement or 2’s Complement as it is also termed, is another method like the previous sign-magnitude and one’s
complement form, which we can use to represent negative binary numbers in a signed binary number system. In two’s
complement, the positive numbers are exactly the same as before for unsigned binary numbers. A negative number, however, is
represented by a binary number, which when added to its corresponding positive equivalent results in zero.
In two’s complement form, a negative number is the 2’s complement of its positive number with the subtraction of two numbers
being A – B = A + ( 2’s complement of B )using much the same process as before as basically, two’s complement is one’s
complement + 1.

The main advantage of two’s complement over the previous one’s complement is that there is no double-zero problem plus it is a
lot easier to generate the two’s complement of a signed binary number. Therefore, arithmetic operations are relatively easier to
perform when the numbers are represented in the two’s complement format.

Let’s look at the subtraction of our two 8-bit numbers 115 and 27 from above using two’s complement, and we remember from
above that the binary equivalents are:

11510 in binary is: 0 1 1 1 0 0 1 1 2


2710 in binary is: 0 0 0 1 1 0 1 1 2

Our numbers are 8-bits long, then there are 28 digits available to represent our values and in binary this
equals: 1000000002 or 25610. Then the two’s complement of 2710 will be:

(28)2 – 00011011 = 100000000 – 00011011 = 111001012

The complementation of the second negative number means that the subtraction becomes a much easier addition of the two
numbers so therefore the sum is: 115 + ( 2’s complement of 27 ) which is:

01110011 + 11100101 = 1 010110002

As previously, the 9th overflow bit is disregarded as we are only interested in the first 8-bits, so the result is: 010110002 or (64 +
16 + 8) = 8810 in decimal the same as before.

Signed Binary Numbers Summary

We have seen that negative binary numbers can be represented by using the most significant bit (MSB) as a sign bit. If an n
bit binary number is signed the leftmost bit is used to represent the sign leaving n-1 bits to represent the number.

For example, in a 4-bit binary number, this leaves only 3 bits to hold the actual number. If however, the binary number is
unsigned then all the bits can be used to represent the number.

The representation of a signed binary number is commonly referred to as the sign-magnitude notation and if the sign bit is “0”,
the number is positive. If the sign bit is “1”, then the number is negative. When dealing with binary arithmetic operations, it is
more convenient to use the complement of the negative number.

Complementation is an alternative way of representing negative binary numbers. This alternative coding system allows for the
subtraction of negative numbers by using simple addition.

Since positive sign-magnitude numbers always start with a zero (0), its complement will therefore always start with a one (1) to
indicate a negative number as shown in the following table.

4-bit Signed Binary Number Comparison


Signed One’s Signed Two’s
Decimal Signed Magnitude
Complement Complement

+7 0111 0111 0111

+6 0110 0110 0110

+5 0101 0101 0101

+4 0100 0100 0100

+3 0011 0011 0011

+2 0010 0010 0010

+1 0001 0001 0001

+0 0000 0000 0000

-0 1000 1111 –

-1 1001 1110 1111

-2 1010 1101 1110

-3 1011 1100 1101

-4 1100 1011 1100

-5 1101 1010 1011

-6 1110 1001 1010

-7 1111 1000 1001

Signed-complement forms of binary numbers can use either 1’s complement or 2’s complement. The 1’s complement and the 2’s
complement of a binary number are important because they permit the representation of negative numbers.

The method of 2’s complement arithmetic is commonly used in computers to handle negative numbers the only disadvantage is
that if we want to represent negative binary numbers in the signed binary number format, we must give up some of the range of
the positive number we had before.
Previous
Binary Numbers Tutorial

Binary Coded Decimal

Binary Coded Decimal, or BCD, is another process for converting decimal numbers into their binary equivalents

As we have seen in this Binary Numbers section of tutorials, there are many different binary codes used in digital and electronic
circuits, each with its own specific use.

As we naturally live in a decimal (base-10) world we need some way of converting these decimal numbers into a binary (base-2)
environment that computers and digital electronic devices understand, and binary coded decimal code allows us to do that.

We have seen previously that an n-bit binary code is a group of “n” bits that assume up to 2n distinct combinations of 1’s and 0’s.
The advantage of the Binary Coded Decimal system is that each decimal digit is represented by a group of 4 binary digits or bits in
much the same way as Hexadecimal. So for the 10 decimal digits (0-to-9) we need a 4-bit binary code.

But do not get confused, binary coded decimal is not the same as hexadecimal. Whereas a 4-bit hexadecimal number is valid up
to F16 representing binary 11112, (decimal 15), binary coded decimal numbers stop at 9 binary 10012. This means that although
16 numbers (24) can be represented using four binary digits, in the BCD numbering system the six binary code combinations
of: 1010 (decimal 10), 1011 (decimal 11), 1100 (decimal 12), 1101 (decimal 13), 1110 (decimal 14), and 1111 (decimal 15) are
classed as forbidden numbers and can not be used.

The main advantage of binary coded decimal is that it allows easy conversion between decimal (base-10) and binary (base-2) form.
However, the disadvantage is that BCD code is wasteful as the states between 1010 (decimal 10), and 1111 (decimal 15) are not
used. Nevertheless, binary coded decimal has many important applications especially using digital displays.

In the BCD numbering system, a decimal number is separated into four bits for each decimal digit within the number. Each
decimal digit is represented by its weighted binary value performing a direct translation of the number. So a 4-bit group
represents each displayed decimal digit from 0000 for a zero to 1001 for a nine.

So for example, 35710 (Three Hundred and Fifty Seven) in decimal would be presented in Binary Coded Decimal as:

35710 = 0011 0101 0111 (BCD)


Then we can see that BCD uses weighted codification, because the binary bit of each 4-bit group represents a given weight of the
final value. In other words, the BCD is a weighted code and the weights used in binary coded decimal code are 8, 4, 2, 1,
commonly called the 8421 code as it forms the 4-bit binary representation of the relevant decimal digit.

Binary Coded Decimal Representation of a Decimal Number

Binary Power 23 22 21 20

Binary Weight: 8 4 2 1

The decimal weight of each decimal digit to the left increases by a factor of 10. In the BCD number system, the binary weight of
each digit increases by a factor of 2 as shown. Then the first digit has a weight of 1 ( 20 ), the second digit has a weight
of 2 ( 21 ), the third a weight of 4 ( 22 ), the fourth a weight of 8 ( 23 ).

Then the relationship between decimal (denary) numbers and weighted binary coded decimal digits is given below.

Truth Table for Binary Coded Decimal

Decimal Number BCD 8421 Code

0 0000 0000

1 0000 0001

2 0000 0010

3 0000 0011

4 0000 0100

5 0000 0101

6 0000 0110

7 0000 0111

8 0000 1000

9 0000 1001
10 (1+0) 0001 0000

11 (1+1) 0001 0001

12 (1+2) 0001 0010

… …

20 (2+0) 0010 0000

21 (2+1) 0010 0001

22 (2+2) 0010 0010

etc, continuing upwards in groups of four

Then we can see that 8421 BCD code is nothing more than the weights of each binary digit, with each decimal (denary) number
expressed as its four-bit pure binary equivalent.

Decimal-to-BCD Conversion

As we have seen above, the conversion of decimal to binary coded decimal is very similar to the conversion of hexadecimal to
binary. Firstly, separate the decimal number into its weighted digits and then write down the equivalent 4-bit 8421 BCD code
representing each decimal digit as shown.

Binary Coded Decimal Example No1

Using the above table, convert the following decimal (denary) numbers: 8510, 57210 and 857910 into their 8421 BCD equivalents.

8510 = 1000 0101 (BCD)


57210 = 0101 0111 0010 (BCD)
857910 = 1000 0101 0111 1001 (BCD)

Note that the resulting binary number after the conversion will be a true binary translation of decimal digits. This is because the
binary code translates as a true binary count.

BCD-to-Decimal Conversion

The conversion from binary coded decimal to decimal is the exact opposite of the above. Simply divide the binary number into
groups of four digits, starting with the least significant digit and then write the decimal digit represented by each 4-bit group. Add
additional zero’s at the end if required to produce a complete 4-bit grouping. So for example, 1101012 would become: 0011
01012 or 3510 in decimal.

Binary Coded Decimal Example No2

Convert the following binary numbers: 10012, 10102, 10001112 and 10100111000.1012into their decimal equivalents.

10012 = 1001BCD = 910


10102 = this will produce an error as it is decimal 1010 and not a valid BCD number
10001112 = 0100 0111BCD = 4710
10100111000.1012 = 0101 0011 0001.1010BCD = 538.62510

The conversion of BCD-to-decimal or decimal-to-BCD is a relatively straight forward task but we need to remember that BCD
numbers are decimal numbers and not binary numbers, even though they are represented using bits. The BCD representation of a
decimal number is important to understand, because microprocessor based systems used by most people needs to be in the
decimal system.

However, while BCD is easy to code and decode, it is not an efficient way to store numbers. In the standard 8421 BCD encoding of
decimal numbers, the number of individual data bits needed to represent a given decimal number will always be greater than the
number of bits required for an equivalent binary encoding.

For example, in binary a three digit decimal number from 0-to-999 requires only 10-bits (11111001112), whereas in binary coded
decimal, the same number requires a minimum of 12-bits (0011 1110 0111BCD) for the same representation.

Also, performing arithmetic tasks using binary coded decimal numbers can be a bit awkward since each digit can not exceed 9.
The addition of two decimal digits in BCD, will create a possible carry bit of 1 which needs to be added to the next group of 4-bits.

If the binary sum with the added carry bit is equal to or less than 9 (1001), the corresponding BCD digit is correct. But when the
binary sum is greater than 9 the result is an invalid BCD digit. Therefore it is better to convert BCD numbers into pure binary,
perform the required addition, and then convert the back to BCD before displaying the results.

Nevertheless, the use of a BCD coding system in both microelectronics and computer systems is particularly useful in situations
where the binary coded decimal is intended to be displayed on one or more 7-segment LED or LCD displays and there are many
popular integrated circuits available that are configured to give a BCD output or outputs.

One common IC is the 74LS90 asynchronous counter/divider that contains independent divide-by-2 and divide-by-5 counters that
can be used together to produce a divide-by-10 decade counter with BCD outputs. Another is the 74LS390 which is a dual version
of the basic 74LS90, and can also be configured to produce a BCD output.

But the most commonly used BCD encoded IC’s are the 74LS47 and the 74LS48 BCD to 7-segment decoder/driver, which converts
a 4-bit BCD code of a counter, etc. and converts it into the required display code to drive the individual segments of a 7-segment
LED display. While both IC’s are functionally the same, the 74LS47 has active-low outputs for driving common-anode displays,
while the 74LS48 has active-high outputs for driving common-cathode displays.

Binary Coded Decimal Decoder IC


Binary Coded Decimal Summary

We have seen here that Binary Coded Decimal or BCD is simply the 4-bit binary code representation of a decimal digit with each
decimal digit replaced in the integer and fractional parts with its binary equivalent. BCD Code uses four bits to represent the 10
decimal digits of 0 to 9.

So for example, if we wanted to display decimal numbers in the range of 0-to-9, (one digit) we would need 4 data bits (a nibble),
decimal numbers in the range of 0-to-99, (two digits) we would need 8 bits (one byte), decimal numbers in the range of 0-to-999,
(three digits) we would need 12 bits, and so on. The use of a single byte (8-bits) to store or display two BCD digits, allowing a byte
to hold a BCD number in the range of 00 – 99, is known as packed BCD.

Standard binary coded decimal code is commonly known as a weighted 8421 BCD code, with 8, 4, 2 and 1 representing the
weights of the different bits starting from the most significant bit (MSB) and proceeding towards the least significant bit (LSB). The
weights of the individual positions of the bits of a BCD code are: 23 = 8, 22 = 4, 21 = 2, 20 = 1.

The main advantage of the Binary Coded Decimal system is that it is a fast and efficient system to convert the decimal numbers
into binary numbers as compared to the pure binary system. But the BCD code is wasteful as many of the 4-bit states (10-to-16)
are not used but decimal displays have important applications.

Previous
Signed Binary Numbers

Binary Fractions
Binary Fractions use the same weighting principle as decimal numbers except that each binary digit uses the base-2
numbering system

We know that decimal (or denary) numbers use the base ten (base-10) numbering system where each digit in a decimal number is
allowed to take one of ten possible values in the range of 0 to 9. So moving from right to left along a decimal number, each digit
will have a value ten times greater than the digit to its immediate right.

But as well as each digit being ten times bigger than the previous number as we move from right-to-left, each digit can also be ten
times smaller than its neighbouring number as we move along in the opposite direction from left-to-right.

However, once we reach zero (0) and the decimal point, we do not need to just stop, but can continue moving from left-to-right
along the digits producing what are generally called Fractional Numbers.

A Typical Fractional Number

Here in this decimal (or denary) number example, the digit immediately to the right of the decimal point (number 5) is worth one
tenth (1/10 or 0.1) of the digit immediately to the left of the decimal point (number 4) which as a multiplication value of one (1).

Thus as we move through the number from left-to-right, each subsequent digit will be one tenth the value of the digit
immediately to its left position, and so on.

Then the decimal numbering system uses the concept of positional or relative weighting values producing a positional notation,
where each digit represents a different weighted value depending on the position occupied either side of the decimal point.

Thus mathematically in the standard denary numbering system, these values are commonly written as: 40, 31, 22, 13 for each
position to the left of the decimal point in our example above. Likewise, for the fractional numbers to right of the decimal point,
the weight of the number becomes more negative giving: 5-1, 6-2, 7-3 etc.

So we can see that each digit in the standard decimal system indicates the magnitude or weight of that digit within the number.
Then the value of any decimal number will be equal to the sum of its digits multiplied by their respective weights, so for our
example above: N = 1234.56710 in the weighted decimal format this will be equal too:

1000 + 200 + 30 + 4 + 0.5 + 0.06 + 0.007 = 1234.56710

or it could be written to reflect the weighting of each denary digit:


(1×1000) + (2×100) + (3×10) + (4×1) + (5×0.1) + (6×0.01) + (7×0.001) = 1234.56710
or even in polynomial form as:
(1×103) + (2×102) + (3×101) + (4×100) + (5×10-1) + (6×10-2) + (7×10-3) = 1234.56710

We can also use this idea of positional notation where each digit represents a different weighted value depending upon the
position it occupies in the binary numbering system. The difference this time is that the binary number system (or simply binary
numbers) is a positional system, where the different weighted positions of the digits are to the power of 2 (base-2) instead of 10.

Binary Fractions

The binary numbering system is a base-2 numbering system which contains only two digits, a “0” or a “1”. Thus each digit of a
binary number can take the “0” or the “1” value with the position of the 0 or 1 indicating its value or weighting. But we can also
have binary weighting for values of less than 1 producing what are called unsigned fractional binary numbers.

Similar to decimal fractions, binary numbers can also be represented as unsigned fractional numbers by placing the binary digits
to the right of the decimal point or in this case, binary point. Thus all the fractional digits to the right of the binary point have
respective weightings which are negative powers of two, creating a binary fraction. In other words, the powers of 2 are negative.

So for the fractional binary numbers to the right of the binary point, the weight of each digit becomes more negative giving: 2-1,
2-2, 2-3, 2-4, and so on as shown.

Binary Fractions
etc, etc.

Thus if we take the binary fraction of 0.10112 then the positional weights for each of the digits is taken into account giving its
decimal equivalent of:

For this example, the decimal fraction conversion of the binary number 0.10112 is 0.687510.

Binary Fractions Example No1

Now lets suppose we have the following binary number of: 1101.01112, what will be its decimal number equivalent.

1101.0111 = (1×23) + (1×22) + (0×21) + (1×20) + (0×2-1) + (1×2-2) + (1×2-3) + (1×2-4)


= 8 + 4 + 0 + 1 + 0 + 1/4 + 1/8 + 1/16
= 8 + 4 + 0 + 1 + 0 + 0.25 + 0.125 + 0.0625 = 13.437510

Hence the decimal equivalent number of 1101.01112 is given as: 13.437510

So we can see that fractional binary numbers, that is binary numbers that have a weighting of less than 1 (20), can be converted
into their decimal number equivalent by successively dividing the binary weighting factor by the value of two for each decrease in
the power of 2, remembering also that 20 is equal to 1, and not zero.

Other Binary Fraction Examples

0.11 = (1×2-1) + (1×2-2) = 0.5 + 0.25 = 0.7510


11.001 = (1×21) + (1×20) + (1×2-3) = 2 + 1 + 0.125 = 3.12510
1011.111 = (1×23) + (1×21) + (1×20) (1×2-1) + (1×2-2) + (1×2-3)

= 8 + 2 + 1 + 0.5 + 0.25 + 0.125 = 11.87510

Converting Decimal to a Binary Fraction


The conversion of a decimal fraction to a fractional binary number is achieved using a method similar to that we used for integers.
However, this time multiplication is used instead of division with the integers instead of remainders used with the carry digit
being the binary equivalent of the fractional part of the decimal number.

When converting from decimal to binary, the integer (positive sequence right-to-left) part and the fractional (negative sequence
from left-to-right) part of the decimal number are calculated separately.

For the integer part of the number, the binary equivalent is found by successively dividing (known as successive division) the
integer part of the decimal number repeatedly by 2 (÷2), noting the remainders in reverse order from the least significant bit (LSB)
to the most significant bit (MSB), until the value becomes “0” producing the binary equivalent.

So to find the binary equivalent of the decimal integer: 11810

118 (divide by 2) = 59 plus remainder 0 (LSB)


59 (divide by 2) = 29 plus remainder 1 (↑)

29 (divide by 2) = 14 plus remainder 1 (↑)


14 (divide by 2) = 7 plus remainder 0 (↑)
7 (divide by 2) = 3 plus remainder 1 (↑)
3 (divide by 2) = 1 plus remainder 1 (↑)
1 (divide by 2) = 0 plus remainder 1 (MSB)

Then the binary equivalent of 11810 is therefore: 11101102 ← (LSB)

The fractional part of the number is found by successively multiplying (known as successive multiplication) the given fractional
part of the decimal number repeatedly by 2 (×2), noting the carries in forward order, until the value becomes “0” producing the
binary equivalent.

So if the multiplication process produces a product greater than 1, the carry is a “1” and if the multiplication process produces a
product less than “1”, the carry is a “0”.

Note also that if the successive multiplication processes does not seem to be heading towards a final zero, the fractional number
will have an infinite length or until the equivalent number of bits have been obtained, for example 8-bits. or 16-bits, etc.
depending on the degree of accuracy required.

So to find the binary fraction equivalent of the decimal fraction: 0.812510

0.8125 (multiply by 2) = 1.625 = 0.625 carry 1 (MSB)


0.625 (multiply by 2) = 1.25 = 0.25 carry 1 (↓)
0.25 (multiply by 2) = 0.50 = 0.5 carry 0 (↓)
0.5 (multiply by 2) = 1.00 = 0.0 carry 1 (LSB)

Thus the binary equivalent of 0.812510 is therefore: 0.11012 ← (LSB)

We can double check this answer using the procedure above to convert a binary fraction into a decimal number
equivalent: 0.1101 = 0.5 + 0.25 + 0.0625 = 0.812510
Binary Fraction Example No2

Find the binary fraction equivalent of the following decimal number: 54.6875

First we convert the integer 54 to a binary number in the normal way using successive division from above.

54 (divide by 2) = 27 remainder 0 (LSB)


27 (divide by 2) = 13 remainder 1 (↑)
13 (divide by 2) = 6 remainder 1 (↑)
6 (divide by 2) = 3 remainder 0 (↑)
3 (divide by 2) = 1 remainder 1 (↑)
1 (divide by 2) = 0 remainder 1 (MSB)

Thus the binary equivalent of 5410 is therefore: 1101102

Next we convert the decimal fraction 0.6875 to a binary fraction using successive multiplication.

0.6875 (multiply by 2) = 1.375 = 0.375 carry 1 (MSB)


0.375 (multiply by 2) = 0.75 = 0.75 carry 0 (↓)
0.75 (multiply by 2) = 1.50 = 0.5 carry 1 (↓)
0.5 (multiply by 2) = 1.00 = 0.0 carry 1 (LSB)

Thus the binary equivalent of 0.687510 is therefore: 0.10112 ← (LSB)

Hence the binary equivalent of the decimal number: 54.687510 is 110110.10112

Binary Fractions Summary

We have seen here in this tutorial about Binary Fractions that to convert any decimal fraction into its equivalent binary fraction,
we must multiply the decimal fractional part, and only the decimal fractional part by 2 and record the digit that appears to the left
of the binary point. This binary digit which is the carry digit will ALWAYS be either a “0” or a “1”.

We must then multiply the remaining decimal fraction by 2 again repeating the above sequence using successive multiplication
until the fraction is reduced to zero or the required amount of binary bits has been completed for a repeating binary fraction.
Fractional numbers are represented by negative powers of 2.

For mixed decimal numbers we must perform two separate operations. Successive division for the integer part to the left of the
decimal point and successive multiplication for the fractional part to the right of the decimal point.

Note that the integer part of a mixed decimal number will always have an exact binary number equivalent but the decimal
fractional part may not, since we could get a repeating fraction resulting in an infinite number of binary digits if we wanted to
represent the decimal fraction exactly.
https://www.electronics-tutorials.ws/binary/binary-fractions.html

Das könnte Ihnen auch gefallen