Presentation is loading. Please wait.

Presentation is loading. Please wait.

Decimal Number System We are used to the decimal number system which is a positional number system The decimal number 4386 represents the value: 41000.

Similar presentations


Presentation on theme: "Decimal Number System We are used to the decimal number system which is a positional number system The decimal number 4386 represents the value: 41000."— Presentation transcript:

0 Internal Information Representation and Processing
CSCE Fundamentals of Computer Science Dr. Awad Khalil Computer Science & Engineering Department The American University in Cairo CSCI Contemporary Computer Design

1 Decimal Number System We are used to the decimal number system which is a positional number system The decimal number 4386 represents the value: 4    1 In general, the decimal number dn dn d1 d0 represents the value: The digit at the left is called the most significant digit The most significant digit has the largest power of ten The digit at the right is called the least significant digit The concept of zero is a cornerstone in the decimal number system. It enables us to multiply by 10 by simply adding a zero as a least significant digit. Similarly, we can divide by zero by remove the least significant zero or inserting a decimal point. 1234  10 = / 10 = 123.4 Internal Information Representation - slide 1 Fundamentals of Computer Science – Awad Khalil

2 Other Radices The positional number system is called also the Arabic number system (the Arabs have discovered the 0) Other bases (called also radices) are possible A digit in base b is between 0 and b-1 Base 10 digits: 0, 1, …, 9 (called also decimal digits) Base 2 digits: 0 and 1 (called also binary digits or bits) Base 3 digits: 0, 1, 2 Base 8 digits: 0, 1, …, 7 (called also octal digits) Base 16 digits: 0, 1, …, 9, A, B, C, D, E, F (called also hexadecimal digits) The number (dn dn d1 d0)b represents the value: Examples: (207)8 = 2    80 = = 135 (1011)2 = 1     20 = = 11 Internal Information Representation - slide 2 Fundamentals of Computer Science – Awad Khalil

3 Binary, Octal, and Hexadecimal Number Systems
Computers use the binary number system Two binary digits: 0 and 1 called bits In the hardware circuitry, 0 represents LOW voltage, while 1 represents HIGH voltage Information inside the computer is represented by 0’s and 1’s The integer values 0 to 16, represented in four number systems are shown below: A B C D E F Decimal Binary Octal Hexadecimal Advantages of the octal and hexadecimal numbers: Reduce the length of numbers Are more readable than binary numbers Can be easily converted to/from binary Internal Information Representation - slide 3 Fundamentals of Computer Science – Awad Khalil

4 Conversions between Number Systems
A number in base b can be easily converted to base 10 using the following equation: Examples: We can also convert a decimal number N to obtain the number (dn dn d1 d0 )b in base b using the following algorithm: (2012)3 = 2     30 = = 59 (A0F)16 = 10    160 = = 2575 i := 0; q := N; repeat di := q mod b; q := q div b; i := i + 1; until q = 0; Question: Convert 50 to base 2 Answer: d0 = 50 mod 2 = 0, q = 50 div 2 = 25 d1 = 25 mod 2 = 1, q = 25 div 2 = 12 d2 = 12 mod 2 = 0, q = 12 div 2 = 6 d3 = 6 mod 2 = 0, q = 6 div 2 = 3 d4 = 3 mod 2 = 1, q = 3 div 2 = 1 d5 = 1 mod 2 = 1, q = 1 div 2 = 0 Thus, 50 = (110010)2 Question: Convert 50 to base 3 Answer: d0 = 50 mod 3 = 2, q = 50 div 3 = 16 d1 = 16 mod 3 = 1, q = 16 div 3 = 5 d2 = 5 mod 3 = 2, q = 5 div 3 = 1 d3 = 1 mod 3 = 1, q = 1 div 3 = 0 Thus, 50 = (1212)3 Internal Information Representation - slide 4 Fundamentals of Computer Science – Awad Khalil

5 More Conversions Answer:
Suppose we want to convert a number from base 3 to base 2, we can convert it first to base 10 and then to base 2 Example: Convert (1012)3 to base 2 Answer: (1012)3 = 1     30 = = 32 d0 = 32 mod 2 = 0, q = 32 div 2 = 16 d1 = 16 mod 2 = 0, q = 16 div 2 = 8 d2 = 8 mod 2 = 0, q = 8 div 2 = 4 d3 = 4 mod 2 = 0, q = 4 div 2 = 2 d4 = 2 mod 2 = 0, q = 2 div 2 = 1 d5 = 1 mod 2 = 1, q = 1 div 2 = 0 Thus, (1012)3 = 32 = (100000)2 It is easy to convert numbers between the binary, octal, and hexadecimal systems Every 3 binary digits can be converted into an octal digit starting at the least significant bit Every 4 binary digits can be converted into a hexadecimal digit Example: ( )2 = (246)8 = (A6)16 Internal Information Representation - slide 5 Fundamentals of Computer Science – Awad Khalil

6 Computer Representation of Information
Basic unit of information is the Bit or Binary digit. With a single bit, we can represent two distinct values 0 and 1. With two bits, we can represent four distinct values: 00, 01, 10, and 11. In general, with m bits, we can represent 2m distinct values. A byte is a grouping of 8 bits. A word is a grouping of either 16, 32, or 64 bits, depending on the computer system. A word is typically 32 bits on most systems, a half word is 16 bits, and a double word is 64 bits. Bit = 0 or 1 Byte = 8 bits Half Word = 2 bytes = 16 bits Word = 4 bytes = 32 bits Long Word = 8 bytes = 64 bits Internal Information Representation - slide 6 Fundamentals of Computer Science – Awad Khalil

7 Binary Addition The addition of 3 bits a + b + c produces a sum bit and a carry bit. Signed Integers are represented in 2’s complement notation. Addition of integers in 2’s complement notation results in a signed integer. Although a carry out is produced in the 2nd and 4th computations, it is ignored. Examples: carry  carry  –19 –82 sum  sum  –101 sum  –8 sum  a b c carry sum a + b + c Internal Information Representation - slide 7 Fundamentals of Computer Science – Awad Khalil

8 The Discipline of Computing
Computing is a relatively young academic discipline. We distinguish between applications of the computer within other disciplines such as business, engineering, and sciences, and the nature of computing itself. Peter Denning gave the following broad definition of the field of Computer Science: Computer Science is the body of knowledge dealing with the design, analysis, implementation, efficiency, and application of processes that transform information. The fundamental question underlying all of computer science is "what can be automated?" Nine general subject areas combine to make up the discipline of Computing. These are shown below: Internal Information Representation - slide 8 Fundamentals of Computer Science – Awad Khalil

9 The Discipline of Computing
Internal Information Representation - slide 9 Fundamentals of Computer Science – Awad Khalil


Download ppt "Decimal Number System We are used to the decimal number system which is a positional number system The decimal number 4386 represents the value: 41000."

Similar presentations


Ads by Google