Csc159-Chapter 2 Part1

March 23, 2018 | Author: Zainulsyafiq Ank En Din | Category: Byte, Bit, Numbers, Computer Data, Arithmetic


Comments



Description

MACHINE LEVEL REPRESENTATION OF DATA (Part 1) Prepared by: Nor Fauziah Binti Abu Bakar, FSKM Contents Bits, bytes, and words 2. Numeric data representation and number bases – Binary, Octal, Hexadecimal 3. Conversion between bases 1. Bits, Bytes, and Words Bits  The basic unit of information in computing and     telecommunication In computing, a bit is defined as a variable or computed quantity that can have only two possible These two values are often interpreted as binary digits and are usually denoted by 0 and 1 In several popular programming languages, numeric 0 is equivalent (or convertible) to logical false, and 1 to true. The correspondence between these values and the physical states of the underlying storage or device is a matter of convention, and different assignments may be used even within the same device or program that most commonly consists of eight bits  a byte was the number of bits used to encode a single character of text in a computer and it is for this reason the basic addressable element in many computer architectures. Bytes.  The byte size and byte addressing are often used in place of longer integers for size or speed optimizations in microcontrollers and CPUs .Bits. and Words .cont Bytes  a unit of digital information in computing and telecommunications. is most often a word .Bits. Bytes.  The size of a word is reflected in many aspects of a computer's structure and operation.cont Words  In computing. and Words . word is a term for the natural unit of data used by a particular computer design  A word is simply a fixed sized group of bits that are handled together by the system  The number of bits in a word (the word size or word length) is an important characteristic of computer architecture. in a single operation. the majority of the registers in the computer are usually word sized and the amount of data transferred between the processing part computer and the memory system. 953125 X 103 1/512 16-3 2.015625 1/64 16-2 3.001 1/1000 2-3 0.125 1/8 165 HEXADECIMAL 1.096 162 256 161 16 160 1 ● 16-1 0.01 1/100 2-2 0.5 1/2 85 OCTAL 32.768 84 4.096 83 512 82 64 81 8 80 1 ● 8-1 0.906 X 103 1/256 3RD PLACE 10-3 0.1 1/10 2ND PLACE 10-2 0.NUMBERING SYSTEM : PLACE BASE 5TH PLACE 105 4TH PLACE 104 10.125 1/8 8-3 1.0625 1/16 .048.441406 2 X 104 1/4096 DECIMAL 100.000 2ND PLACE 102 100 1ST PLACE 101 10 SINGLE UNIT 100 1 ● ● 1ST PLACE 10-1 0.536 163 4.000 25 BINARY 32 24 16 23 8 22 4 21 2 20 1 ● 2-1 0.25 1/4 8-2 0.57 6 164 65.000 3RD PLACE 103 1.  hexadecimal 45 will be written as 45h  octal 76 will be written as 76o or 76q  binary 11010011 will be written as 11010011b . decimal. a single lowercase letter appended to the end of each number to identify its type.Number Bases  Radix :  when referring to binary. octal.  E.g. hexadecimal. Number System The following table shows the equivalent values for decimal numbers in binary. octal and hexadecimal: .  Binary system: system of positional notation based powers of 2  Octal system: system of positional notation based on powers of 8  Hexadecimal system: system of positional notation based powers of 16 .Number System  Decimal system: system of positional notation based on powers of 10. 8.1 0.3.A.7.1.5.7.4.1. 3.1.2.C.6.4.Number System  Base:  The number of different symbols required to represent any given number  The larger the base.5.F  For a given number. 2.8.D.6.6.7 0. the more numerals are required  Base 10:  Base 2:  Base 8:  Base 16 : 0. the larger the base  the more symbols required  but the fewer digits needed .B.E.9 0.9.5.3.2.4. Number System EXAMPLE:  Example #1: 6516 10110  Example #2:  11C16 28410  1458 4348 110 01012 1 0001 11002 . Binary System WHY??  Early computer design was decimal  Mark I and ENIAC  John von Neumann proposed binary data processing (1945)  Simplified computer design  Used for both instructions and data  Natural relationship between on/off switches and calculation using Boolean logic On True Yes Off False No 1 0 . 010000010100001001001000011 = “ABC” .  represent these entities with numbers requires a system geared to the concept of on and off or true and false  Binary is a base 2 numbering system  each digit is either a 0 (off) or a 1 (on)  Computers store all instructions and data as sequences of binary digit  e.Binary System  A computer stores both instructions and data as individual electronic charges.g. Binary System  Each digit in binary number has a value depending on its position  Example:  The number 1002 means  (1 X 2²) + ( 0 X 2¹) + (0 X 2º) 4+0+0 4 . Base 2 7/21/2013 15 .  Example : The number 472810 means :  (4 X 1000) + (7 X 100) + (2 X 10) + 8  4000 + 700 + 20 +8  4728 .Decimal System  Decimal is a base 10 numbering system  We use a system based on decimal digits to represent numbers  Each digit in the number is multiplied by 10 raised to a power corresponding to that digit position. Base 10 7/21/2013 17 . 4. 1. 3. 7)  Example : The number 7238 means  (7 X 8²) + (2 X 8¹) + (3 X 8º)  448 + 16 + 3  467 .Octal System  As known as base 8 numbering system  There are only eight different digits available (0. 6. 5. 2. Base 8 7/21/2013 19 . Hexadecimal System  Hexadecimal is a base 10 numbering system  Used not only to represent integers  Also used to represent sequence of binary digits  Example : The number 2C16 means:  (2 X 16¹) + (C X 16º)  32+ 12  44 . Base 16 7/21/2013 21 . Conversion of binary to octal 6. Conversion of decimal to octal 3. Conversion of binary to hexadecimal 7. Conversion of decimal to hexadecimal 4.Conversion Between Bases 1. Conversion of octal to binary 9. Conversion of decimal to binary 2. Conversion of hexadecimal to binary 10.Conversion of hexadecimal to decimal . Conversion of binary to decimal 5. Conversion of octal to decimal 8. CONVERSION : DECIMAL  OTHER BASES . From Base 10 to Base 2 Base 10 Quotient 2) 42 Remainder 42 ( 0 Least significant bit 2) 2) 2) 2) 2) Base 2 21 10 5 2 1 0 (1 (0 (1 (0 (1 101010 Most significant bit . From Base 10 to Base 2 Convert 3710 to binary. 37 ÷ 2 18 ÷ 2 9÷2 4÷2 2÷2 1÷2 = = = = = = 18 9 4 2 1 0 balance balance balance balance balance balance 1 0 1 0 0 1 (LSB) (MSB) Therefore . 3710 = 1001012 * MSB (most-significant-bit) : left most bit LSB (least-significant-bit) : right most bit . 7500 X 2 1.6875 method.10112 . then dropped and the process repeated So.6875)10 = (0.687510 in binary? Steps : 1.0000 The 1 is saved as result.5000 X 2 1. 2. (0.From Base 10 (decimal point) to Base 2 What is the value of 37. X (MSB) 1 0 1 (LSB) 1 2 1. Convert the decimal point to binary by using the following 0. Therefore.687510 = 100101. Convert the integer to binary by using method shown in previous slide. 37.3750 X 2 0.1011)2 . From Base 10 to Base 8 Base 10 135 Remainder 135 ( 7 Least significant bit 16 ( 0 2 ( 2 Most significant bit 0 Base 8 207 Quotient 8) 8) 8) . 25 8 2. 21.28 .00 x Therefore.From Base 10 (decimal point) to Base 8 Convert 21.2510 = 25. 8 21 8 2 0 5 2 2 0.2510 to octal. 012 0. 0. 0102 = 25.50 X 2 1. Refer to conversion of binary to hexadecimal 21.28 .2510 = 010 101 .2510 to octal.00 Therefore.25 X 2 0. (MSB) 0 1 (MSB) (LSB) So.2510 = 0. (OTHER METHOD) 21 ÷ 2 = 10 10 ÷ 2 = 5 5÷2 = 2 2÷2 = 1 1÷2 = 0 So.From Base 10 (decimal point) to Base 8 Convert 21. 2110 = 101012 balance balance balance balance balance 1 0 1 0 1 (LSB) Now. From Base 10 to Base 16 Base 10 5.735 ( 7 Least significant bit 358 ( 6 22 ( 6 1 ( 1 Most significant bit 0 Base 16 1667 Quotient 16 ) 16 ) 16 ) 16 ) .735 Remainder 5. 039 ( 7 Least significant bit 502 ( 6 31 ( 15 1 ( 1 Most significant bit 0 Base 16 1F67 .039 Remainder 8.From Base 10 to Base 16 Base 10 Quotient 16 ) 16 ) 16 ) 16 ) 8. 21 ÷ 16 1 ÷ 16 = = 1 balance 5 0 balance 1 (LSB) (MSB) Therefore .From Base 10 to Base 16 Convert 2110 to hexadecimal. 2110 = 1516 . 25 16 4.2510 = 15.00 x Therefore.416 .2510 to hexadecimal. 21. 16 21 16 1 0 5 1 4 0.From Base 10 (decimal point) to Base 16 Convert 21. (OTHER METHOD) 21 ÷ 2 = 10 10 ÷ 2 = 5 5÷2 = 2 2÷2 = 1 1÷2 = 0 So.416 .2510 = 10101 . 2110 = 101012 balance balance balance balance balance 1 0 1 0 1 (LSB) Now.2510 = 0.25 X 2 0.00 Therefore. (MSB) 0 1 (MSB) (LSB) So. Refer to conversion of binary to hexadecimal 21.2510 to hexadecimal.012 0. 0.From Base 10 (decimal point) to Base 16 Convert 21. 01002 = 15.50 X 2 1. 5610 base 8 (until 5 binary point) 2.62510. .2510 to hexadecimal. Show your work. Find the binary representation for 31. 1. Convert the following numbers to the respective numbering system.EXERCISES 1. Convert 95.
Copyright © 2024 DOKUMEN.SITE Inc.