240 likes | 446 Vues
Information Science 1 -Representation of Data in Memory-. College of Information Science and Engineering Ritsumeikan University. Week 03. Topics covered. Basic terms and concepts of “The Structure of a Computer” Positional numbering systems decimal binary octal hexadecimal
E N D
InformationScience 1-Representation of Datain Memory- College of Information Science and EngineeringRitsumeikan University Week 03
Topics covered • Basic terms and concepts of “The Structure of a Computer” • Positional numbering systems • decimal • binary • octal • hexadecimal • Conversion among different bases • to decimal • from decimal • other conversions • Quiz
Recall Week 02 • Digital system • Data • Binary • Memory, RAM • Bit, Byte, Computer Word, Address • CPU • CU, ALU, MAR, MDR, IR, GPR, PC, PSW • Machine Cycle, Fetch, Execute • Input, Output • Computer Bus
The objectives of this class • To understand the fundamentals of numerical data representation and manipulation in computers • Master the skill of representing (decimal) numbers in the binary, octal, and hexadecimal systems • To be able to speak aloud a number in any of the four bases • To be able to convert from decimal to the above three numbering systems
Recall: Computer as a digital system • A bit is the most basic (and, hence, the smallest) unit of information in a computer • It is a state of “on” or “off” in a digital circuit • Sometimes these states are also called as “high” or “low” (voltage) • A byte is a group of eight bits • A byte is the smallest (in principle) addressable unit of computer storage • “Addressable” means that a particular byte can be retrieved according to its location
00111100010110001010011000110111101 Computer words and nibbles • A word is a contiguous group of bytes • Words can be any number of bytes or bits (word sizes of 32 or 64 bits are now most common • In a word-addressable system, a word is the smallest addressable unit of memory storage • A group of four bits is called a nibble (or nybble) • A byte, therefore, consists of two nibbles:a “high-order” nibble, and a “low-order” nibble
Positional numbering system • A positional numbering system (or positional notation system) is a numeral system in which each digit is related to the next by a constant multiplier called the base or radix of that system • The value of each digit position is, therefore, the value of its digit multiplied by a power of the base, where the power is determined by the digit's position counted from the separator (which is usually a dot “.” or comma “,”) • The value of a number is then calculated as the sum of the values of all positions
Decimal system • Decimal numbers have radix = 10 (in Latin, “decima” means “a tenth part”) • Symbols used:0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 • Position weights:… 103 102 101 100 . 10-1 10-2 10-3 …1000 100 10 1 1/10 1/100 1/1000 • For example, the decimal number 36.250:36.250 = 3*10 + 6*1+ 2*1/10 + 5* 1/100 +0* 1/1000
Binary system • Binary numbers have radix = 2 (in Latin, “bini” means “two together”) • Symbols used:0 and 1 • The radix (10) is denoted by a subscript (2 • Position weights:… 23 22 21 20 . 2-1 2-2 2-3 …8 4 2 1 1/2 1/4 1/8 • For example, the binary equivalent of 36.250:36.250 = 1*32 + 1*4 + 1/4 = 100100.01(2
Octal system • Octal numbers have radix = 8 (in Latin, “octo” means eight) • Symbols used:0, 1, 2, 3, 4, 5, 6, and 7 • Convenient when bits are grouped in triplets • Position weights:… 83 82 81 80 . 8-1 8-2 2-3 …512 64 8 1 1/8 1/64 1/512 • For example, the octal equivalent of 36.250:36.250 = 4*8 + 4*1 + 2*1/8 = 44.2(8
Hexadecimal system • Hexadecimal numbers have radix = 16 (in Greek, “hexa” means six) • Symbols used:0, …, 9, A, B, C, D, E, and F • Convenient to represent nibbles (hextets) • Position weights:… 163 162 161 160 . 16-1 16-2 16-3 …4096 256 16 1 1/16 1/256 1/4096 • For example, the hexadecimal equivalent of 36.250: 36.250 = 2*16 + 4*1 + 4*1/16 = 24.4(16
Radix r numbers • For any radix r number represented with n+m+1 digits asNumber(ran...a1a0 . a-1...a-m,its decimal equivalent is calculated as follows:Number(10=anrn +...+a1r1 +a0 +a-1r-1 +...+a-mr–m=
Conversion among different systems • We already learned these 3 conversions: Decimal Octal Hexadecimal Binary • There still remain 9 other possible conversions
Converting decimal to another base • The rule • Left of the separator (i.e. of the decimal point): repeatedly divide the integer part by the radix and write the remainders (R) right to left • Right of the separator: repeatedly multiply the fractional part by the radix and write the integer portion (I) of the result left to right
Example: Decimal to binary 22.8125 = ?(2 22.8125 = 10110(2. 11 R 0 5 R 1 2 R 1 1 R 0 0 R 1 22.8125 = .1101(2 1.625 I 1 1.25 I 1 0.5 I 0 1.0 I 1 0 I 0 22.8125 = 10110.1101(2
Other examples 1234 = ?(8 1234 = ?(16 1234 = 2322(8 154 R 2 19 R 2 2 R 3 0 R 2 1234 = 4D2(16 77 R 2 4 R 13 = D 0 R 4
The remaining conversions • To convert between binary, octal, and hexadecimal, memorize and use the conversion table: • Octal is 3 bits for each digit • Hexadecimal is 4 bits for each digit • Use binary as the intermediate to convert between octal and hexadecimal 0110100110.1(2 = ?(8 = ?(16 000 110 100 110.100 0001 1010 0110.1000 6 4 6 .4 1 A 6 .8 0110100110.1(2 = 646.4(8 = 1A6.8(16
Key points of this lecture • Because binary numbers are the basis for all data representation in digital systems, it is important that you become proficient with the binary system to understand the operation of all computer components as well as the design of computer architectures • The binary system is the most important positional numbering system for computers
Key points (cont-d) • It is, however, difficult to read long strings of bits, and even a modestly-sized decimal number becomes a very long binary number • For example, 1359510 = 11010100011011(2 • For compactness and ease of reading, binary values are usually expressed using the octal or hexadecimal system • To convert among the different systems, use the conversion algorithms and, when appropriate, the conversion table
Homework • Get the slides & self-preparation information fromhttp://www.ritsumei.ac.jp/is/~rinaldo/InfoScience1/InfoScience1.html • Read these slides again and learn the new terms
Next class • Representation of data in memory (2) • Basic computer operation