Chapter 2 Number System PDF

Document Details

IntimateResilience8736

Uploaded by IntimateResilience8736

Carlos Hilado Memorial State University

Mark Jarus T. Talanquines

Tags

number systems binary decimal computer science

Summary

This document is a presentation about number systems, covering topics like binary, decimal, octal, and hexadecimal number systems in computer science.

Full Transcript

Chapter 2 Number System Presented By: MARK JARUS T. TALANQUINES Assistant Professor II TABLE OF CONTENTS NO: LIST OF TOPICS Topic 1: Number System Topic 2: Binary Topic 3: Decimal Topic 4: Octal Topic 5: Hexadecimal Topic 6: Other Number System Topic 7: S...

Chapter 2 Number System Presented By: MARK JARUS T. TALANQUINES Assistant Professor II TABLE OF CONTENTS NO: LIST OF TOPICS Topic 1: Number System Topic 2: Binary Topic 3: Decimal Topic 4: Octal Topic 5: Hexadecimal Topic 6: Other Number System Topic 7: Some Terminologies Topic 1 Number System Number System Number systems are systems in mathematics that are used to express numbers in various forms and are understood by computers. A number is a mathematical value used for counting and measuring objects, and for performing arithmetic calculations. Numbers have various categories like natural numbers, whole numbers, rational and irrational numbers, and so on. Similarly, there are various types of number systems that have different properties, like the binary number system, the octal number system, the decimal number system, and the hexadecimal number system. Number System Con… There are different types of number systems in which the four main types are as follows. 1. Binary number system (Base - 2) 2. Octal number system (Base - 8) 3. Decimal number system (Base - 10) 4. Hexadecimal number system (Base - 16) Number System Con… Given below is a chart of the main four types of number system that we use to represent numbers. Topic 2 Binary Numbers BINARY 1. Binary Number System is a number system that is used to represent various numbers using only two symbols “0” and “1”. The word binary is derived from the word “bi” which means two. Hence, this number system is called Binary Number System. Thus, the binary number system is a system that has only two symbols. CONTINUATION… The binary number system uses only two digits: 0 and 1. The numbers in this system have a base of 2. Digits 0 and 1 are called bits and 8 bits together make a byte. The data in computers is stored in terms of bits and bytes. The binary number system does not deal with other numbers such as 2,3,4,5 and so on. For example: 100012, 1111012, 10101012 are some examples of numbers in the binary number system. CONTINUATION… Computers store information using binary numbers o All information that is processed by computers is converted in one way or another into a sequence of numbers. This includes numeric information textual information and pictures. o Therefore, if we can derive a way to store and retrieve numbers electronically this method can be used by computers to store and retrieve any type of information. Information is stored using binary numbers o A binary number is simply a bunch of 1’s and 0’s o CD’s that are created in a factory (we’re not talking about CD-R’s yet) may look perfectly flat. However, there are many microscopic “bumps” on the surface of the CD. o The bumps are laid out in a spiral form on the surface of the CD. CONTINUATION… Binary Numbers are at the heart of how a computer stores all information o Computers store all information using Binary Numbers o Computers use binary numbers in different ways to store different types of information. Common types of information that are stored by computers are: Whole numbers (i.e. Integers). Examples: 8 97 -732 0 -5 etc. Numbers with decimal points. Examples: 3.5 -1.234 0.765 999.001 etc. Textual information. (including letters, symbols and digits) Integers (e.g. 87) A computer stores integer numbers (i.e. “whole” numbers) simply as the equivalent binary value for that number. Why do 0 to 9 have ASCII values? Numbers that are used in mathematical calculations If a computer needs to do math with a number it will store that number using the appropriate binary representation of the number. This makes it easier for the computer to perform mathematical calculations with the number. Example: 5 would be stored as 00000101 Numbers that are NOT used in mathematical calculations If the computer does NOT need to do math with the number (e.g. a zip code) then it will generally store the number using the ASCII values of the digits. In this case using the ASCII value is more efficient (for reasons we will not explain here). Example 5 would be stored using its ASCII value of 53 which is represented in binary as 00110101 Conversion of Number Systems A number can be converted from one number system to another number system using number system formulas. Like binary numbers can be converted to octal numbers and vice versa, octal numbers can be converted to decimal numbers and vice versa, and so on. Let us see the steps required in converting number systems. Steps for Conversion of Binary to Decimal Number System To convert a number from the binary to the decimal system, we use the following steps. Step 1: Multiply each digit of the given number, starting from the rightmost digit, with the exponents of the base. Step 2: The exponents should start with 0 and increase by 1 every time we move from right to left. Step 3: Simplify each of the above products and add them. Example: Convert 1001112 into the decimal system. Solution: Step 1: Identify the base of the given number. Here, the base of 1001112 is 2. Step 2: Multiply each digit of the given number, starting from the rightmost digit, with the exponents of the base. The exponents should start with 0 and increase by 1 every time as we move from right to left. Since the base is 2 here, we multiply the digits of the given number by 20, 21, 22 , and so on from right to left. Example: Convert 1001112 into the decimal system. Example: Convert 1001112 into the decimal system. Step 3: We just simplify each of the above products and add them. Topic 3 Decimal Numbers Decimal Number System The decimal number system uses ten digits: 0,1,2,3,4,5,6,7,8 and 9 with the base number as 10. The decimal number system is the system that we generally use to represent numbers in real life. If any number is represented without a base, it means that its base is 10. For example, 72310, 3210, and 425710 are some examples of numbers in the decimal number system. Steps for Conversion of Decimal to Binary Number System Decimal to binary conversion is done through various methods. One of the methods to convert decimal to binary is by dividing the given decimal number recursively by 2. Then, the remainders are noted down till we get 0 as the final quotient. After this step, these remainders are written in reverse order to get the binary value of the given decimal number. A number system is a mathematical way of representing numbers using a set of digits or symbols. There are different number systems like the decimal number system, the binary number system, the octal, and the hexadecimal number system. These are identified with the help of the base that they have. Numbers can be easily converted from one base to another using some defined rules. Steps for Conversion of Decimal to Binary Number System The decimal number system is a number system that represents a number with a base of 10 and uses 10 symbols - 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. It is also known as the Hindu-Arabic number system in which each digit has a position and it is ten times more significant than the previous digit. It also uses a decimal point to represent decimal fractions. For example, if we take 36 as a decimal number, here, 3 is ten times more than 6. Decimal numbers are written as 4510, 11810, and so on. It is the most commonly known number system in which the numbers can be identified easily even if the base is not written. In other words, if the base of a number is not written, it is considered to be a decimal number. Steps for Conversion of Decimal to Binary Number System To convert numbers from decimal to binary, the given decimal number is divided repeatedly by 2 and the remainders are noted down till we get 0 as the final quotient. The following steps is considered as the decimal to binary formula that shows the procedure of conversion. Steps for Conversion of Decimal to Binary Number System Step 1: Divide the given decimal number by 2 and note down the remainder. Step 2: Now, divide the obtained quotient by 2, and note the remainder again. Step 3: Repeat the above steps until you get 0 as the quotient. Step 4: Now, write the remainders in such a way that the last remainder is written first, followed by the rest in the reverse order. Step 5: This can also be understood in another way which states that the Least Significant Bit (LSB) of the binary number is at the top and the Most Significant Bit (MSB) is at the bottom. This number is the binary value of the given decimal number. Example: Convert the decimal number 1310 to binary. Solution: We will start dividing the given number (13) repeatedly by 2 until we get the quotient as 0. We will note the remainders in order. Example: Convert the decimal number 1310 to binary. After noting the remainders, we will write them in such a way that the Most Significant Bit (MSB) of the binary number is written first, followed by the rest. Therefore, the binary equivalent for the given decimal number 1310 is 11012. This means that 1310 = 11012. Topic 4 Octal Numbers Octal Number System The octal number system uses eight digits: 0,1,2,3,4,5,6 and 7 with the base of 8. The advantage of this system is that it has lesser digits when compared to several other systems, hence, there would be fewer computational errors. Digits like 8 and 9 are not included in the octal number system. Just like the binary, the octal number system is used in minicomputers but with digits from 0 to 7. For example, 358, 238, and 1418 are some examples of numbers in the octal number system. Topic 5 Hexadecimal Numbers Hexadecimal Number System The hexadecimal number system uses sixteen digits/alphabets: 0,1,2,3,4,5,6,7,8,9 and A,B,C,D,E,F with the base number as 16. Here, A-F of the hexadecimal system means the numbers 10-15 of the decimal number system respectively. This system is used in computers to reduce the large-sized strings of the binary system. For example, 7B316, 6F16, and 4B2A16 are some examples of numbers in the hexadecimal number system. Topic 6 Other Number System Other Numbering Systems ASCII - ASCII was the standard numbering system for many years and is still used widely today. EBCDIC - Is a different numbering system used by IBM Mainframe computers. It is very similar to ASCII but uses different numbers to represent the symbols. EBCDIC stands for “Extended Binary Coded Decimal Interchange Code”. Unicode - ASCII and EBCDIC are limited to just the basic English letters and common symbols. Today computers use many different symbols including letters from languages that don’t use English letters (e.g. Hebrew, Chinese, etc.) and international symbols (e.g. the English pound sign) Unicode defines a unique number for every symbol in all known languages (e.g. Hebrew, Chinese, etc.) and commonly used non-letter symbols (e.g. English pound sign, copyright symbol, etc.). Modern programs are moving towards using Unicode to store letters and symbols. It should be noted that Unicode numbers 1-128 correspond to the EXACT SAME symbols as ASCII 1-128 EBCDIC - Extended Binary Coded Decimal Interchange Code ASCII - American Standard Code for Information Interchange Unicode Topic 7 Some Terminologies Some terminology in Computing The following are some terms that are used in the computer field Each digit of a binary number is called a bit. A binary number with eight bits (i.e. digits) is called a byte. Terms (bit, byte, etc.) BIT - definition: a single Binary digit (i.e. BIT) BYTE - definition: 8 bits NYBLE - definition: 4 bits Prefixes Kilo: one thousand Mega: one million Giga: one billion Tera: one trillion Peta: one quadrillion … etc. Some terminology in Computing Data sizes 1. Kilobyte (KB) "about" one thousand bytes exactly 210 or 1024 bytes 2. Megabyte (MB)"about" one million bytes exactly 220 or 1,048,576 bytes 3. Gigabyte (GB)"about" one billion bytes exactly 230 or 1,073,741,824 bytes 4. Terabyte (TB)"about" one trillion bytes exactly 240 or 1,099,511,627,776 bytes Data Sizes – bytes vs bits 1. MB = one Mega Byte 2. Mb = one Mega Bit Speeds 1. MBPS = one Mega Byte per second 2. MbPS = one Mega Bit per second REFERENCES 1. Ritchi, D. M., & Kernighan, B. W. (2021). C programming language (2nd ed.). 2. Gookin, D. (2020). C programming for dummies. John Wiley & Sons. 3. McGrath, M. (2018). C programming in easy steps: Updated for the GNU compiler version 6.3.0 and Windows 10 (5th ed.). In Easy Steps. REFERENCES 4. C programming language tutorial. (2024, June 10). GeeksforGeeks. https://www.geeksforgeeks.org/c- programming-language/?ref=shm 5. W3Schools.com. (n.d.). W3Schools Online Web Tutorials. https://www.w3schools.com/c/index.php 6. C tutorial. (n.d.). Quality Tutorials, Video Courses, and eBooks.https://www.tutorialspoint.com/cprogramming/index. htm The End of Chapter! Email: [email protected] Website: Pending..

Use Quizgecko on...
Browser
Browser