2. Data Conversion

Question.6

Which of the following 4-bit binary configurations correctly fits in the blank to complete the conversion?

B7E (hexadecimal) = 1011____1110 (binary)

Need Help? Refer to the Quick Guide below

Digital Electronics

Digital electronics processes information using separate or discrete values.

The word digital comes from digit, which means a number symbol.

Digital circuits normally use two logic levels:

  • 0 – LOW
  • 1 – HIGH

Positive and Negative Logic

Logic defines how voltage levels represent binary values.

Table 1: Logic Conventions

Logic TypeHIGH VoltageLOW Voltage
Positive logic10
Negative logic01

Positive logic is used more widely in digital circuits.

Importance of Number Systems

Number systems are used to:

  • Represent digital data
  • Store values in registers
  • Perform arithmetic operations
  • Write memory addresses
  • simplify long binary values

 

Number Systems

A number system uses a fixed set of digits and a base.

The value of each digit depends on its position:

Value = Digit × Baseᵖᵒˢⁱᵗⁱᵒⁿ

Table 2: Common Number Systems

Number SystemBaseDigitsSequence ExampleData Example
Decimal100 to 98, 9, 10, 1145₁₀
Binary20, 10, 1, 10, 11, 100101101₂
Octal80 to 76, 7, 10, 1155₈
Hexadecimal160 to 9, A to FE, F, 10, 112D₁₆

In hexadecimal:

  • A = 10
  • B = 11
  • C = 12
  • D = 13
  • E = 14
  • F = 15

 

Data Conversion Techniques

The same value will be used in all examples:

45₁₀ = 101101₂ = 55₈ = 2D₁₆

 

Decimal to Other Number Systems

Decimal to Binary

Repeatedly divide the decimal number by 2.

Write the remainders from bottom to top.

Example: Convert 45₁₀ to Binary

DivisionQuotientRemainder
45 ÷ 2221
22 ÷ 2110
11 ÷ 251
5 ÷ 221
2 ÷ 210
1 ÷ 201

Reading upward:

45₁₀ = 101101₂

Decimal to Octal

Repeatedly divide the decimal number by 8.

45 ÷ 8 = 5, remainder 5

5 ÷ 8 = 0, remainder 5

Therefore:

45₁₀ = 55₈

Decimal to Hexadecimal

Repeatedly divide the decimal number by 16.

45 ÷ 16 = 2, remainder 13

13 = D

Therefore:

45₁₀ = 2D₁₆

Table 3: Decimal Conversion Summary

Required SystemDivision BaseResult for 45₁₀
Binary2101101₂
Octal855₈
Hexadecimal162D₁₆

 

Binary to Other Number Systems

Binary to Decimal

Multiply every binary bit by its positional weight.

101101₂
= 1×2⁵ + 0×2⁴ + 1×2³ + 1×2² + 0×2¹ + 1×2⁰
= 32 + 8 + 4 + 1
= 45₁₀

Binary to Octal

Group binary bits into sets of 3, starting from the right.

101 101

  • 101₂ = 5₈
  • 101₂ = 5₈

Therefore:

101101₂ = 55₈

Binary to Hexadecimal

Group binary bits into sets of 4, starting from the right.

Add leading zeros when required:

0010 1101

  • 0010₂ = 2₁₆
  • 1101₂ = D₁₆

Therefore:

101101₂ = 2D₁₆

Table 4: Binary Conversion Summary

Required SystemMethodResult for 101101₂
DecimalPositional weights45₁₀
OctalGroup into 3 bits55₈
HexadecimalGroup into 4 bits2D₁₆

 

Octal to Other Number Systems

Octal to Binary

Replace each octal digit with its 3-bit binary value.

5₈ = 101₂

Therefore:

55₈ = 101 101₂

55₈ = 101101₂

Octal to Decimal

Multiply every digit by its positional weight.

55₈
= 5×8¹ + 5×8⁰
= 40 + 5
= 45₁₀

Octal to Hexadecimal

First convert octal to binary:

55₈ = 101101₂

Group the binary value into 4 bits:

0010 1101

Therefore:

55₈ = 2D₁₆

Table 5: Octal Conversion Summary

Required SystemMethodResult for 55₈
BinaryReplace each digit with 3 bits101101₂
DecimalPositional weights45₁₀
HexadecimalOctal → Binary → Hexadecimal2D₁₆

 

Hexadecimal to Other Number Systems

Hexadecimal to Binary

Replace each hexadecimal digit with its 4-bit binary value.

  • 2₁₆ = 0010₂
  • D₁₆ = 1101₂

Therefore:

2D₁₆ = 0010 1101₂

Removing leading zeros:

2D₁₆ = 101101₂

Hexadecimal to Decimal

Multiply every digit by its positional weight.

2D₁₆
= 2×16¹ + 13×16⁰
= 32 + 13
= 45₁₀

Hexadecimal to Octal

First convert hexadecimal to binary:

2D₁₆ = 00101101₂

Group the bits into sets of 3:

00 101 101

101₂ = 5₈

Therefore:

2D₁₆ = 55₈

Table 6: Hexadecimal Conversion Summary

Required SystemMethodResult for 2D₁₆
BinaryReplace each digit with 4 bits101101₂
DecimalPositional weights45₁₀
OctalHexadecimal → Binary → Octal55₈

 

Conversion Shortcuts

Table 7: Number-System Conversion Methods

FromToMethod
DecimalBinary, Octal or HexadecimalRepeated division by required base
BinaryDecimalAdd positional weights
BinaryOctalGroup into 3 bits
BinaryHexadecimalGroup into 4 bits
OctalBinaryReplace each digit with 3 bits
HexadecimalBinaryReplace each digit with 4 bits
OctalHexadecimalConvert through binary
HexadecimalOctalConvert through binary

 

Binary Arithmetic

Signed Binary Representation

Signed binary numbers represent both positive and negative values.

The most significant bit is used as the sign bit:

  • Sign bit 0: Positive
  • Sign bit 1: Negative

The remaining bits represent the value.

Sign-Magnitude Range

For an n-bit sign-magnitude number:

Range = −(2ⁿ⁻¹ − 1) to +(2ⁿ⁻¹ − 1)

For 4 bits:

Range = −7 to +7

Sign-magnitude has two zero values:

  • 0000 = +0
  • 1000 = −0

 

Binary Addition

Binary addition follows four basic rules.

Table 8: Binary Addition Rules

AdditionSumCarry
0 + 000
0 + 110
1 + 010
1 + 101
1 + 1 + 111

Example

   1011
 + 0110
 -------
  10001
1011₂ = 11₁₀
0110₂ = 6₁₀
10001₂ = 17₁₀

 

1's Complement

The 1's complement of a binary number is found by inverting every bit.

  • Change 0 to 1.
  • Change 1 to 0.

Example

Original number:

0101

Invert all bits:

1010

Therefore, in 4-bit 1's complement:

  • +5 = 0101
  • −5 = 1010

Limitation

1's complement has two representations of zero:

  • Positive zero: 0000
  • Negative zero: 1111

Addition may also require an end-around carry.

 

2's Complement

The 2's complement is found in two steps:

  1. Find the 1's complement.
  2. Add 1.

Example: Find −5

Positive 5:

0101

1's complement:

1010

Add 1:

  1010
+ 0001
------
  1011

Therefore:

−5 = 1011

Range

For an n-bit 2's complement number:

Range = −2ⁿ⁻¹ to +(2ⁿ⁻¹ − 1)

For 4 bits:

Range = −8 to +7

Benefits

  • Only one representation of zero
  • Simple addition and subtraction
  • Widely used in processors and digital circuits

Table 9: Signed Binary Representations

Representation+5−54-Bit RangeZero Values
Sign-magnitude01011101−7 to +7Two
1's complement01011010−7 to +7Two
2's complement01011011−8 to +7One

 

Binary Subtraction

Binary subtraction uses borrowing, similar to decimal subtraction.

Basic rules:

  • 0 − 0 = 0
  • 1 − 0 = 1
  • 1 − 1 = 0
  • 0 − 1 requires a borrow

After borrowing:

10₂ − 1₂ = 1₂

Example

   10110
 - 00101
 --------
   10001
10110₂ = 22₁₀
00101₂ = 5₁₀
10001₂ = 17₁₀

 

Subtraction Using 2's Complement

Binary subtraction can be changed into addition:

A − B = A + 2's complement of B

Example: 10110 − 00101

Step 1: Find 2's Complement of 00101

1's complement:

11010

Add 1:

11011

Step 2: Add It to 10110

   10110
 + 11011
 --------
 1 10001

Discard the final carry:

10001

Therefore:

10110₂ − 00101₂ = 10001₂

Result Rule

  • Final carry present: Discard the carry. The result is positive.
  • No final carry: Take the 2's complement of the result and add a negative sign.

 

Binary Codes

Binary codes represent numbers, characters or changing states using binary bits.

 

Gray Code

Gray code is a binary code in which two consecutive values differ by only one bit.

It is also called a unit-distance code.

Example

DecimalBinaryGray
0000000
1001001
2010011
3011010

Properties

  • Only one bit changes between adjacent values.
  • It is a non-weighted code.
  • It reduces transition errors.
  • It is not normally used for arithmetic.

Applications

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

 

BCD Code

BCD means Binary-Coded Decimal.

Each decimal digit is represented separately using four binary bits.

BCD normally uses the 8421 weighted code.

Example

Decimal value:

59

  • 5 = 0101
  • 9 = 1001

Therefore:

59₁₀ = 0101 1001 in BCD

BCD 1010 to 1111 are invalid decimal-digit codes.

Properties

  • Each decimal digit uses four bits.
  • It is a weighted code.
  • Decimal digits remain separate.
  • It requires more bits than pure binary.

Applications

  • Calculators
  • Digital clocks
  • 7-segment displays
  • Decimal measurement systems

 

Excess-3 Code

Excess-3 represents each decimal digit after adding 3 to it.

Example

Convert decimal 59:

For digit 5:

5 + 3 = 8 = 1000₂

For digit 9:

9 + 3 = 12 = 1100₂

Therefore:

59₁₀ = 1000 1100 in Excess-3

Properties

  • It is a non-weighted code.
  • It is a self-complementing code.
  • Each decimal digit uses four bits.
  • It is derived from BCD by adding 0011.

Applications

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

 

ASCII Code

ASCII means American Standard Code for Information Interchange.

It represents:

  • Letters
  • Numbers
  • Symbols
  • Control characters

Standard ASCII uses 7 bits.

Examples

  • A = 65₁₀ = 1000001₂
  • a = 97₁₀ = 1100001₂
  • 0 = 48₁₀ = 0110000₂

Properties

  • Represents 128 standard characters.
  • It is used for character data, not arithmetic values.
  • Extended ASCII systems commonly use 8 bits.
  • Uppercase and lowercase letters have different codes.

Applications

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

 

Binary-Code Comparison

Table 10: Binary Code Comparison

CodeMain PurposeTypeExampleMain Application
GrayRepresent changing positionsNon-weightedDecimal 2 = 011Rotary encoders
BCDRepresent decimal digitsWeighted 8421Decimal 59 = 0101 1001Displays and calculators
Excess-3Represent decimal digits with offsetNon-weightedDecimal 59 = 1000 1100Decimal arithmetic
ASCIIRepresent charactersCharacter codeA = 1000001Text communication

 

Select Answer

Restart quiz!