1.3
1.3
BINARY CODES
3.1 THE NEED FOR BINARY REPRESENTATION
Binary representation is essential in computing due to its simplicity and compatibility with digital
electronic circuits. Here's why:
1. Simplicity of Implementation:
∙ On/Off States: Binary only uses two states: "0" and "1," which can be easily represented by the
presence or absence of an electrical signal.
∙ Transistor Logic: Transistors, the fundamental building blocks of digital circuits, are naturally
suited for binary operations. They can be used to perform logical operations like AND, OR, and
NOT.
∙ Fast Processing: Binary operations are relatively simple and can be performed very quickly by
computers.
∙ Compact Storage: Binary data can be stored efficiently in a compact format, using a minimal
number of bits.
4. Mathematical Foundations:
∙ Boolean Algebra: Binary operations are based on Boolean algebra, a mathematical system that
provides the foundation for digital logic.
Binary representation is the way data is stored and processed in computers. It uses a base-2 system,
meaning there are only two possible values: 0 and 1. These values are often represented by the
presence or absence of an electrical signal.
Why Binary?
∙ Simplicity: Computers are built using electronic circuits that are naturally suited for binary
operations.
∙ Efficiency: Binary operations can be performed very quickly by computers.
∙ Standardization: Binary is a universal language understood by all computers, regardless of their
hardware or software.
Binary representation is a system of representing numbers using only two digits: 0 and 1. This system
is used in computers because they are built on electronic circuits that can only handle "on" (1) or "off"
(0) states.
Unsigned Integers
∙ Place Values: Each position in a binary number represents a power of 2. For example, the rightmost
position represents 2^0 (1), the next position represents 2^1 (2), and so on.
∙ Conversion: To convert a decimal number to binary, repeatedly divide the decimal number by 2
and keep the remainders. The remainders, read from bottom to top, form the binary representation.
∙ 13 / 2 = 6 remainder 1
∙ 6 / 2 = 3 remainder 0
∙ 3 / 2 = 1 remainder 1
∙ 1 / 2 = 0 remainder 1
Signed Integers
∙ Positive and Negative Numbers: Can represent both positive and negative numbers. ∙ Two's
Complement: A common method for representing signed integers is two's complement. To find the
two's complement of a number, invert all the bits and add 1.
∙ Conversion: To convert a negative decimal number to binary, first convert its absolute value to
binary and then find its two's complement.
Floating-Point Numbers
Characters are represented in computers using a specific encoding scheme that assigns a unique
numerical value to each character. This numerical value is then converted to binary for storage and
processing.
∙ ASCII (American Standard Code for Information Interchange): One of the oldest and most
widely used character encoding standards. It uses 7 bits to represent 128 characters, including letters,
numbers, punctuation marks, and control characters.
10
∙ UTF-8: A variable-length encoding scheme that can represent characters from almost all languages
in the world. It is compatible with ASCII and can use 1, 2, 3, or 4 bytes to represent a character. ∙
UTF-16: Another variable-length encoding scheme that can represent characters from almost all
languages. It uses 2 or 4 bytes to represent a character.
1. Character Lookup: The character to be represented is looked up in the encoding scheme's table.
2. Numerical Value: The corresponding numerical value is found for the character. 3. Binary
Conversion: The numerical value is converted to binary.
Example:
n computing, characters are represented by binary codes in a system called ASCII (American Standard
Code for Information Interchange) or Unicode, depending on the encoding scheme used. Each
character is assigned a unique numerical code, which is then represented in binary form.
∙ Character 'A'
o ASCII code: 65
o Binary representation: 01000001
∙ Character 'a'
o ASCII code: 97
o Binary representation: 01100001
∙ Character '0'
o ASCII code: 48
o Binary representation: 00110000
∙ Character ' ' (space)
o ASCII code: 32
o Binary representation: 00100000
These binary representations are typically 8 bits long (one byte), but in Unicode, especially with UTF-8
encoding, characters might use more than one byte depending on the character's code point.
11
Discussion Questions
1. How did the invention of Morse code influence global communication, and
what are some of its modern-day applications or equivalents?"
2. How has Braille code transformed accessibility for individuals with visual
impairments, and what challenges and innovations exist today in expanding
its use in a digital world?"
3. In what ways does the binary system differ from other number systems like
decimal or hexadecimal, and why is binary particularly well-suited for
representing data in computers?"
12