Summary

This document provides an introduction to different number systems, including binary, decimal, hexadecimal, and octal. It explains the historical development of number systems, and the process of converting between them. The document also covers place value and whole numbers.

Full Transcript

NUMBER SYSTEMS Introduction to Number Systems and Types of Number Systems 1. Introduction to Number Systems 1.1 Definition and Purpose  In programming, number systems are ways to represent numbers. The main ones are binary (base 2), decimal (base 10), hexadecimal (bas...

NUMBER SYSTEMS Introduction to Number Systems and Types of Number Systems 1. Introduction to Number Systems 1.1 Definition and Purpose  In programming, number systems are ways to represent numbers. The main ones are binary (base 2), decimal (base 10), hexadecimal (base 16), and octal (base 8).  Binary uses 0s and 1s and is the language computers understand because it matches their on/off electrical signals. Decimal is the system we use every day, with digits 0 to 9.  Hexadecimal is used to shorten long binary numbers, making them easier to work with, especially in tasks like memory addressing or color codes. Octal is rarely used today but appears in some older systems.  These number systems help computers efficiently process and store data. Binary works well with computer hardware, and hexadecimal makes large numbers easier to manage, especially for programmers dealing with low- level code or debugging systems. 1.2 Historical Development of Number Systems  The history of number systems began with early humans using tally marks or objects to count. The Babylonians (c. 2000 BCE) introduced a positional base-60 system, which influenced modern time and angle measurements. The Egyptians and Romans used non-positional systems like hieroglyphic numbers and Roman numerals, which were less efficient for calculations.  A major advance came with the Hindu-Arabic system (around 500 CE), which introduced zero and a base-10 positional system—the system we use today. This innovation revolutionized math and laid the foundation for modern computation. Later, binary, octal, and hexadecimal systems were developed for computing purposes, shaping today’s digital world. 2. Types of Number Systems Decimal Number System  The decimal system is a base-10 number system, meaning it uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. It is the system we use for everyday counting and calculations. Base 10 and Place Value: In the decimal system, the position of a digit in a number determines its value. Each position is a power of 10: The first position (far right) is the ones place. The second position is the tens place. The third is the hundreds place, and so on. For example, in 425: The 4 is in the hundreds place, so it represents 400. The 2 is in the tens place, so it represents 20. The 5 is in the ones place, so it represents 5. So, 425 is really 400 + 20 + 5. Whole Numbers:  Whole numbers are written using only digits in the places to the left of the decimal point. For example, 3621 means: 3 in the thousands place (3000), 6 in the hundreds place (600), 2 in the tens place (20), and 1 in the ones place (1), which together is 3621. Fractions (Decimal Points):  When a number includes a decimal point, it represents fractions. The digits to the right of the decimal point represent parts of a whole:  The first digit is the tenths place ( 1/10​).  The second digit is the hundredths place (1/100), and so on. For example, in 34.56: 34 is the whole number part. 5 is in the tenths place, so it’s 0.5. 6 is in the hundredths place, so it’s 0.06. So, 34.56 is 34 + 0.5 + 0.06. Binary Number System The binary system is a number system that uses only two digits: 0 and 1. It is also called a base-2 system because each position in a binary number represents a power of 2. The binary system is essential in computers and digital systems because they operate using two states: on (1) and off (0). Base 2 and Binary Digits (0s and 1s): In the binary system, similar to the decimal system, each digit's place has a value depending on its position. However, instead of powers of 10 (as in the decimal system), binary uses powers of 2: The first position is the ones place (20). The second position is the twos place (21). The third position is the fours place (22), and so on. For example, in the binary number 101: The rightmost 1 is in the ones place ( 20 =1 ), The middle 0 is in the twos place ( 21=2, but it represents 0 because the digit is 0), The leftmost 1 is in the fours place ( 22=4 ). So, 101 in binary is equal to 4 + 0 + 1 = 5 in decimal. Converting Binary to Decimal: To convert a binary number to decimal, you can follow these steps: Write down the binary number and list the powers of 2 from right to left. Multiply each binary digit by its corresponding power of 2. Add up all the results. Let's take the binary number 101 as an example. Write it down: Binary: 1 0 1 Powers of 2: 22, 21, 20 (which are 4, 2, and 1). Multiply each digit: 1 x 22 = 1 x 4 = 4 0 x 21 = 0 x 2 = 0 1 x 20 = 1 x 1 = 1 Add the results: 4+0+1=5 So, 101 in binary equals 5 in decimal. Octal number system The octal number system is a positional numeral system that uses base 8, meaning it has eight unique digits: 0, 1, 2, 3, 4, 5, 6, 7. Each digit's position represents a power of 8, starting from 808 0 at the rightmost digit, increasing as you move left (81, 82, 83 etc.). For example : The octal number 157 translates to decimal as: (1×82)+(5×81)+(7×80)=64+40+7=111 Octal Representation - Uses digits 0 to 7. - Each position represents powers of 8 (e.g., 8^0, 8^1, 8^2). - Example: 347_8 = (3 × 8^2) + (4 × 8^1) + (7 × 8^0) = 231_10. Conversions 1. Octal to Decimal: Multiply each digit by 8^n (position power) and sum. Example: 258 = 16 + 5 = 2110. 2. Decimal to Octal: Repeatedly divide by 8; read 3. Binary to Octal: Group binary digits in 3's; convert each group. Example: 1101112 → 678. 4. Octal to Binary: Convert each octal digit to a 3-bit binary group. Example: 528 → 1010102. Applications of the Octal Number System in Computing 1. Simplifying Binary Representation: Octal is used to simplify binary numbers by grouping bits in sets of three. This reduces the length and complexity of binary representations. Example: A byte (8 bits) can be represented as two octal digits. 2. Memory Addressing: In some computer systems, memory addresses are often expressed in octal to make them shorter and easier to read compared to binary. 3. File Permissions in Unix/Linux: In Unix and Linux systems, file permissions are represented using octal numbers. Each digit corresponds to read, write, and execute permissions for user, group, and others. 4. Efficient Storage: Since each octal digit corresponds to exactly three binary digits, octal is a compact way of representing binary data, especially in systems with limited display space. 5. Debugging and Programming: Octal is used in low-level programming and debugging to represent binary values more succinctly, making it easier to inspect memory content or machine-level operations. Hexadecimal Number System  The hexadecimal number system is a base-16 system that uses 16 digits: 0-9 and A-F, where A=10, B=11, C=12, D=13, E=14, and F=15.  Each position represents a power of 16 (e.g., 160, 161, 162).  Hexadecimal is commonly used in computing as a more compact representation of binary numbers, as each hex digit corresponds to 4 binary digits (bits).  For example, the binary number 110111112 is DF16 in Base 16  Base 16, also called hexadecimal, is a number system that uses 16 different symbols: 0-9 and A-F. The digits A-F represent the numbers 10 to 15.  Hexadecimal is often used in computers because it can represent large binary numbers more easily, as every 4 binary digits (bits) can be written as a single hexadecimal digit. In the base 16 (hexadecimal) system, the digits range from 0 to 9 and A to F, where: - 0-9 represent the values 0 to 9. - A represents the value 10. - B represents the value 11. - C represents the value 12. - D represents the value 13. - E represents the value 14. - F represents the value 15. For example: - Hexadecimal 2A3 means: (2 × 16^2) + (A × 16^1) + (3 × 16^0), where A = 10, so it’s equivalent to: (2 × 256) + (10 × 16) + (3 × 1) = 512 + 160 + 3 = 675 in decimal. Hexadecimal to Decimal Conversion: Multiply each hex digit by 16 raised to its position power, then sum the results. Example: Convert 2A3 (hex) to decimal: - 2 × 16^2 = 512, A × 16^1 = 160 (A = 10), 3 × 16^0 = 3 Result: 512 + 160 + 3 = 675 (decimal). Decimal to Hexadecimal Conversion: Divide the decimal by 16 repeatedly, reading the remainders from bottom to top. Example: Convert 675 (decimal) to hexadecimal: - 675 ÷ 16 = 42 remainder 3 - 42 ÷ 16 = 2 remainder A - 2 ÷ 16 = 0 remainder 2 Result: 2A3 (hexadecimal). Binary to Hexadecimal Conversion: Group binary digits in sets of four, then convert each group to hex. Example: Convert 11011111 (binary) to hexadecimal: - 1101 = D, 1111 = F Result: DF (hexadecimal). Hexadecimal to Binary Conversion: Convert each hex digit to a 4-bit binary equivalent. Example: Convert 2A3 (hex) to binary: - 2 = 0010, A = 1010, 3 = 0011 Result: 001010100011 (binary).

Use Quizgecko on...
Browser
Browser