2. Data Conversion

Question.4

From the options provided below, identify the largest 8-bit binary number.

Need Help? Refer to the Quick Guide below

Digital Electronics

Digital electronics processes the information using discrete values or logic levels.

Digital circuits represent binary values using voltage ranges.

In a simplified 5 V logic example,

5 VLogic 1
0 V or GNDLogic 0

Actual HIGH and LOW voltage thresholds depend on the logic family.

Number Systems

Decimal Number System

Digits: 0 to 9. (0,1,2,3,4,5,6,7,8,9)

Base = 10

Examples: - 3, 5, 87, 123, 543

Commonly used by humans for everyday numerical representation.

Binary Number System

Digits: 0 and 1

Base = 2

Examples: - 0, 1, 10, 1001, 00110101, 1110001011010100

It is used in digital electronics because it enables –

  • Easy implementation.
  • High reliability.
  • Simple circuit design.

Octal Number System

Digits: 0 to 7 (0,1,2,3,4,5,6,7)

Base = 8

Examples: - 4, 7, 34, 23, 17 (Digits 8 and 9 do not appear in an octal number.)

Octal provides a compact representation of binary because one octal digit corresponds to three binary bits.

Hexadecimal Number System

Digits: 0 to 9 and A to F (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)

Base = 16

Examples: - 2, 4, C, D, 3D, 2A, 23B, BD8, 45F

  • Used to represent long binary numbers in a compact form.
  • One hexadecimal digit corresponds to four binary bits.

Number System Conversion Table (0–20)

DecimalBinaryOctalHexadecimal
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
17100012111
18100102212
19100112313
20101002414

Data Conversion

Same value can be represented in different number systems.

Decimal to Binary

Decimal number 45 is converted into binary with following method:

DivisionQuotientRemainder
45 ÷ 2221 (LSB)
22 ÷ 2110
11 ÷ 251
5 ÷ 221
2 ÷ 210
1 ÷ 201 (MSB)
45₁₀ = 101101₂

Binary to Decimal

To convert binary number 10101 into decimal:

Position (n)43210
Binary digits: (from MSB to LSB)10101
Positional Weights: 2ⁿ168421
Product of Weights and binary digit160401
Sum16 + 0 + 4 + 0 + 1 = 21

Examples:

10101₂ = 21₁₀
110111₂ = 55₁₀
1001₂ = 9₁₀

For an n-bit unsigned binary number, the maximum value is 2ⁿ − 1.

For 3-bit, highest value is 2³ – 1 = 8 – 1 = 7
For 4-bit, highest value is 2⁴ – 1 = 16 – 1 = 15

Binary to Octal

Group 3 Binary Digits from LSB and write equivalent Octal Digit

Examples:

101100₂ = (101 100)₂ = 54₈
1011₂ = (001 011)₂ = 13₈

Octal to Binary

Represent each Octal digit to its equivalent 3-digit Binary Number

Examples: -

34₈ = (011 100)₂ = 011100₂
65₈ = (110 101)₂ = 110101₂

Binary Equivalent Octal Table

BinaryOctal
0000
0011
0102
0113
1004
1015
1106
1117

Binary to Hexadecimal

Group 4 Binary Digits from LSB and write equivalent Hexadecimal Digit

Examples:

00110111₂ = (0011 0111)₂ = 37₁₆
10100010₂ = (1010 0010)₂ = A2₁₆
11101011₂ = (1110 1011)₂ = EB₁₆

Hexadecimal to Binary

Represent each Hexadecimal Digit to its equivalent 4-digit Binary or 4-bit Binary

5F₁₆ = (0101 1111)₂ = 01011111₂
3D9₁₆ = (0011 1101 1001)₂ = 001111011001₂
A54₁₆ = (1010 0101 0100)₂ = 101001010100₂

Binary equivalent Hexadecimal

BinaryHexadecimalBinaryHexadecimal
0000010008
0001110019
001021010A
001131011B
010041100C
010151101D
011061110E
011171111F

Decimal to Hexadecimal

Convert the Decimal into Binary and convert the Binary into Hexadecimal

Example: Decimal number = 78₁₀

DivisionQuotientRemainder
78 ÷ 2390 (LSB)
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201 (MSB)
78₁₀ = 1001110₂ = (0100 1110)₂ = 4E₁₆
78₁₀ = 4E₁₆

Hexadecimal to Decimal

Convert the Hexadecimal into Binary and convert the Binary into Decimal

Example: - Hexadecimal number = D4₁₆

D4₁₆ = (1101 0100)₂ = 11010100₂
Position (n)76543210
Binary digits: (from MSB to LSB)11010100
Positional Weights: 2ⁿ1286432168421
Product of Weights and binary digit128640160400
Sum128 + 64 + 0 + 16 + 0 + 4 + 0 + 0 = 212
D4₁₆ = 212₁₀

Octal to Decimal

Convert the Octal to Binary and then Binary to Decimal.

31₈ = (011 001)₂ = 11001₂ = 25₁₀
123₈ = (001 010 011)₂ = 1010011₂ = 83₁₀
234₈ = (010 011 100)₂ = 10011100₂ = 156₁₀

Decimal to Octal

Convert the Decimal to Binary and then Binary to Octal.

15₁₀ = 1111₂ = (001 111)₂ = 17₈
52₁₀ = 110100₂ = (110 100)₂ = 64₈
197₁₀ = 11000101₂ = (011 000 101)₂ = 305₈

Hexadecimal to Octal

Convert Hexadecimal to Binary and then Binary to Octal.

Example: - Hexadecimal Number: - 72C₁₆

Hexadecimal Number:72C
Equivalent Binary Number:011100101100
Equivalent Octal Number3454
4F0₁₆ = (0100 1111 0000)₂ = (010 011 110 000)₂ = 2360₈
AD₁₆ = (1010 1101)₂ = (010 101 101)₂ = 255₈

Octal to Hexadecimal

Convert Octal to Binary and then Binary to Hexadecimal.

Examples: -

31₈ = (011 001)₂ = (0001 1001)₂ = 19₁₆
123₈ = (001 010 011)₂ = (0101 0011)₂ = 53₁₆
305₈ = (011 000 101)₂ = (1100 0101)₂ = C5₁₆

Binary Arithmetic

Binary Addition

Suppose A and B are two 1-bit binary numbers. The sum of A and B can be

ABSumCarry
0000
0110
1010
1101

Examples: -

Suppose A = 101 and B = 001

A101
B001
Carry from previous bit 1 
Sum110
011₂ + 011₂ = 110₂
1010₂ + 0110₂ = 10000₂ (Equivalently: 10 + 6 = 16)

Signed Binary Representation

In common signed representations, the MSB indicates the sign.

MSB represents sign bit.

MSB = 0Positive Value
MSB = 1Negative Value

Remaining bits represents value depending on representation method.

Signed Binary Representation Methods:

  1. Sign-Magnitude Representation
  2. 1’s Complement
  3. 2’s Complement

Sign-Magnitude Representation

Represent number as: Sign (MSB) and Magnitude (Remaining Bits).

Example for 4-bit signed magnitude representation.

0101 = +5
1101 = -5

Limitations:

  • Represents 0 twice (1000, 0000)
  • Arithmetic operations become more complex

1’s Complement

Negative Numbers obtained by inverting all bits of positive number

Examples: -

NumbersOperations
-3Given number
011Represent equivalent binary of +3
100Take 1’s complement (invert 1 to 0 and 0 to 1)
+3 = 011
-0 = 111

Limitation: -

  • 1's complement has two representations of zero: 000 for +0 and 111 for −0.

2’s Complement

For Negative Number, after 1’s Complement, 1 is added to the result to generate 2’s Complement

Example for 4-bit binary number: -

NumberOperation
-5Given Number
01014-bit binary representation of +5
10101s compliment
10112s compliment (add 1 to the 1’s compliment)
Range of n-bit signed binary number: −2ⁿ⁻¹ to +(2ⁿ⁻¹ − 1)

3-bit signed binary equivalent decimal integer

Signed BinaryDecimal
100-4
101-3
110-2
111-1
0000
001+1
010+2
011+3

Binary Subtraction

Suppose A and B are 2 1-bit binary numbers.

ABSubtractionBorrow
0000
0111
1010
1100

Examples: - Suppose A = 010 and B = 001

A010
B001
Borrow from previous bit 1 
Subtraction001
0110₂ – 0100₂ = 0010₂ (6 – 4 = 2)
0101₂ – 0111₂ = 1110₂ (5 – 7 = -2,
Here 1110 is 2s complement of 2 representing -2)

Subtraction using 2s complement

A – B can also represent as: A + (-B)

Or it can be written as: A + (2s complement of B)

Example: - A = 0110₂, B = 0100₂ Find: A – B

OperationValues
Write A0110 (+6₁₀)
Write B0100 (+4₁₀)
1s compliment of B1011
2s compliment of B1100
A + 2s compliment of B0110 + 1100 = 1 0010
Discard Carry Bit as it is out of 4-bit range0010 (+2₁₀)

Examples: -

101₂ − 011₂ = 101₂ + 101₂ = 010₂
1011₂ − 0110₂ = 1011₂ + 1010₂ = 0101₂

This method is used to perform addition and subtraction from single adder circuit

Binary Codes

Predefined binary patterns used to represent different types of information in digital circuits.

Gray Code

Two consecutive Gray-code values differ by exactly one bit.

It is used to reduce errors or ambiguity during transitions between consecutive values.

DecimalBinaryGray
0000000
1001001
2010011
3011010
4100110
5101111
6110101
7111100

Applications

  • Rotary encoders
  • Position sensors
  • Shaft-angle measurement
  • Error reduction during state changes

Binary Coded Decimal (BCD)

Each Decimal Digit is separately represented by 4-bit binary number.

Binary values: 1010 to 1111 are invalid in BCD Code

DecimalBCDDecimalBCD
0000050101
1000160110
2001070111
3001181000
4010091001

Examples: -

56 = 0101 0110
93 = 1001 0011
15 = 0001 0101

Applications

  • Calculators
  • Digital clocks
  • 7-segment displays

Decimal measurement systems

Excess-3 Codes

Represent Decimal digit by adding 3 and converting result into binary.

Binary values 0000 to 0010 and 1101 to 1111 are invalid in Excess-3 Code

It is used to simplify decimal arithmetic and complement operations

DecimalExcess-3DecimalExcess-3
0001151000
1010061001
2010171010
3011081011
4011191100

Examples: -

23 = 0101 0110
85 = 1011 1000

Applications

  • Decimal arithmetic circuits
  • Code converters
  • Complement-based decimal operations

ASCII

ASCII stands for American Standard Code for Information Interchange.

Represents – Numbers, Letters, Symbols, Control Characters

1000001 = A
1000010 = B
1100001 = a
0110000 = 0
0100000 = Space
0100001 = !
0111111 = ?

Applications

  • Computer keyboards
  • Text files
  • Serial communication
  • Computer terminals
  • Embedded-system displays

Binary Codes Summary Table

CodeMain PurposeTypeExampleMain Application
GrayRepresent changing positionsNon-weighted7 = 100Rotary encoders
BCDRepresent decimal digitsWeighted 842159 = 0101 1001Displays and calculators
Excess-3Represent decimal digits with offsetNon-weighted12 = 0100 0101Decimal arithmetic
ASCIIRepresent charactersCharacter codeA = 1000001Text communication

Select Answer

Restart quiz!