Docsity

Computer numbering system, Lecture notes of Computer Programming

Toggle sidebar
bg1
Number Systems and Data Representation
1. Introduction
At the heart of computing lies a simple fact: computers only understand two electrical
states on and off. These are represented as the digits 1 and 0. Every form of data that
we see on a computer whether numbers, text, images, or sound has to be converted
into combinations of these two digits. To do this efficiently, computers rely on
different number systems and methods of data representation.
This topics focus is to explore the major number systems (decimal, binary, octal, and
hexadecimal), learn how to convert between them, examine the different coding
schemes for representing characters, and finally, understand how computers represent
data using bits and bytes.
2. Number Systems
A number system is simply a way of writing and interpreting numbers. Each system
uses a set of symbols (digits) and a base (also called radix), which determines how
values are calculated. Humans are most comfortable with the decimal system because
we use ten digits, but computers are designed to operate on the binary system. For
convenience, we also use the octal and hexadecimal systems, as they allow compact
representation of binary values.
2.1 The Decimal Number System (Base 10)
The decimal system is the everyday system of numbers we use in counting,
calculation, and communication. It is based on ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
Each digit in a number has a place value, determined by a power of ten.
For example, the number 4527 can be broken down as follows:
4527=(4×103)+(5×102)+(2×101)+(7×100)4527 = (4 \times 10^3) + (5 \times 10^2) +
(2 \times 10^1) + (7 \times 10^0)4527=(4×103)+(5×102)+(2×101)+(7×100)
This equals 4000 + 500 + 20 + 7. The decimal system is intuitive for humans but not
suitable for computers, which rely on binary.
2.2 The Binary Number System (Base 2)
Binary is the native language of computers. It uses only two digits: 0 and 1. Each
binary digit is known as a bit. The place values in binary are powers of two.
For example, the binary number 1011 can be converted to decimal as:
10112=(1×23)+(0×22)+(1×21)+(1×20)1011_2 = (1 \times 2^3) + (0 \times 2^2) + (1
\times 2^1) + (1 \times 2^0)10112=(1×23)+(0×22)+(1×21)+(1×20)
pf3
pf4
pf5

Partial preview of the text

Download Computer numbering system and more Lecture notes Computer Programming in PDF only on Docsity!

Number Systems and Data Representation

1. Introduction At the heart of computing lies a simple fact: computers only understand two electrical states on and off. These are represented as the digits 1 and 0. Every form of data that we see on a computer whether numbers, text, images, or sound has to be converted into combinations of these two digits. To do this efficiently, computers rely on different number systems and methods of data representation. This topics focus is to explore the major number systems (decimal, binary, octal, and hexadecimal), learn how to convert between them, examine the different coding schemes for representing characters, and finally, understand how computers represent data using bits and bytes. 2. Number Systems A number system is simply a way of writing and interpreting numbers. Each system uses a set of symbols (digits) and a base (also called radix), which determines how values are calculated. Humans are most comfortable with the decimal system because we use ten digits, but computers are designed to operate on the binary system. For convenience, we also use the octal and hexadecimal systems, as they allow compact representation of binary values. 2.1 The Decimal Number System (Base 10) The decimal system is the everyday system of numbers we use in counting, calculation, and communication. It is based on ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each digit in a number has a place value, determined by a power of ten. For example, the number 4527 can be broken down as follows: 4527=(4×103)+(5×102)+(2×101)+(7×100)4527 = (4 \times 10^3) + (5 \times 10^2) + (2 \times 10^1) + (7 \times 10^0)4527=(4×103)+(5×102)+(2×101)+(7×100) This equals 4000 + 500 + 20 + 7. The decimal system is intuitive for humans but not suitable for computers, which rely on binary. 2.2 The Binary Number System (Base 2) Binary is the native language of computers. It uses only two digits: 0 and 1. Each binary digit is known as a bit. The place values in binary are powers of two. For example, the binary number 1011 can be converted to decimal as: 10112=(1×23)+(0×22)+(1×21)+(1×20)1011_2 = (1 \times 2^3) + (0 \times 2^2) + ( \times 2^1) + (1 \times 2^0)10112=(1×23)+(0×22)+(1×21)+(1×20)

This equals 8 + 0 + 2 + 1 = 11 in decimal. Binary is efficient for computers because electrical circuits can easily represent two states: on (1) and off (0). 2.3 The Octal Number System (Base 8) Octal uses eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. It is useful as a shorthand for binary because every three binary digits correspond to one octal digit. For instance, the octal number 257 can be expanded in decimal as: 2578=(2×82)+(5×81)+(7×80)257_8 = (2 \times 8^2) + (5 \times 8^1) + (7 \times 8^0)2578=(2×82)+(5×81)+(7×80) This equals 128 + 40 + 7 = 175 in decimal. Although less common today, octal was historically popular in older computer systems because it simplified long binary sequences. 2.4 The Hexadecimal Number System (Base 16) Hexadecimal is widely used in programming and computer systems. It uses sixteen symbols: 0 to 9 and the letters A to F, where A stands for 10, B for 11, up to F which represents 15. Each hexadecimal digit is equivalent to four binary digits (a nibble). For example, the hexadecimal number 2F is calculated as: 2F16=(2×161)+(15×160)2F_{16} = (2 \times 16^1) + (15 \times 16^0)2F =(2×161)+(15×160) = 32 + 15 = 47 in decimal. Programmers and computer engineers prefer hexadecimal because it allows large binary numbers to be represented in a compact and human-friendly form.

3. Conversion Between Number Systems It is often necessary to convert numbers from one base to another, especially when working between human-readable formats and machine-level representations. 3.1 Decimal to Binary, Octal, or Hexadecimal The common method is repeated division by the target base while recording remainders. For example, converting 45 from decimal to binary involves dividing by 2 repeatedly until the quotient is zero. The remainders read from bottom to top give the binary result: 4510=101101245_{10} = 101101_24510=

characters differently from ASCII. Although rarely used today, it played a major role in early computing. 4.3 Unicode With globalization and the rise of digital communication, ASCII was insufficient. Unicode was introduced as a universal character set that supports characters from virtually all world languages, mathematical symbols, and even emojis. Unicode can represent over 143,000 characters and is implemented using encodings such as UTF-8, UTF-16, and UTF-32. For example, the letter 'A' is represented as U+0041 in Unicode.

5. Data Representation in Computers All data in a computer is stored in binary, but different kinds of information numbers, text, images, sound need special methods of representation. 5.1 Bits and Bytes The smallest unit of data is the bit, which can be either 0 or 1. A collection of eight bits makes a byte, which is often used to store a single character. Storage and memory sizes are usually expressed in multiples of bytes: 1 Kilobyte (KB) = 1024 bytes 1 Megabyte (MB) = 1024 KB 1 Gigabyte (GB) = 1024 MB 5.2 Numbers Integers are represented in binary. Negative numbers are often stored using a method called two’s complement, which allows easy arithmetic operations. Real numbers are stored in a binary version of scientific notation called floating-point representation, which uses separate fields for the sign, exponent, and fraction. 5.3 Text Text data is represented using character coding schemes like ASCII or Unicode. For instance, the word “Hi” in ASCII is stored as two bytes: the letter 'H' corresponds to 72 (binary 01001000), and 'i' corresponds to 105 (binary 01101001). 5.4 Images, Audio, and Video Images are represented as collections of tiny dots called pixels, each pixel storing color values (such as red, green, and blue levels). Audio is stored by sampling sound waves at small intervals and converting the samples into binary numbers. Video combines images and audio, often compressed to save storage space.

6. Conclusion Number systems and data representation form the backbone of computing. Decimal numbers are natural for humans, but computers rely on binary. Octal and hexadecimal provide compact ways of working with binary data. Conversion between these systems is crucial for programmers and engineers. Beyond numbers, character coding schemes such as ASCII and Unicode allow computers to handle text and symbols. Finally, all data from numbers to multimedia is ultimately reduced to bits and bytes for storage and processing. A solid understanding of these concepts is essential for deeper exploration into computer architecture, programming, and digital systems. It shows how the simple states of “on” and “off” combine to form the rich digital world we experience every day.