Phần cứng - Chapter 2: Bits, data types & operations

Base 16 (hexadecimal) More a convenience for us humans than a true computer data type 0 to 9 represented as such 10, 11, 12, 13, 14, 15 represented by A, B, C, D, E, F 16 = 24: i.e. every hexadecimal digit can be represented by a 4-bit binary (unsigned) and vice-versa. Example

ppt17 trang | Chia sẻ: huyhoang44 | Lượt xem: 547 | Lượt tải: 0download
Bạn đang xem nội dung tài liệu Phần cứng - Chapter 2: Bits, data types & operations, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
Chapter 2Bits, Data Types & Operations Integer Representation Floating-point Representation Logic OperationsData typesOur first requirement is to be able to represent information (data) in a form that is mutually comprehensible by human and machine.Ultimately, we will have to develop schemes for representing all conceivable types of information - language, images, actions, etc.We will start by examining different ways of representing integers, and look for a form that suits the computer.Specifically, the devices that make up a computer are switches that can be on or off, i.e. at high or low voltage. Thus they naturally provide us with two symbols to work with: we can call them on & off, or (more usefully) 0 and 1.2Decimal Numbers“decimal” means that we have ten digits to use in our representation (the symbols 0 through 9)What is 3,546?it is three thousands plus five hundreds plus four tens plus six ones.How about negative numbers?we use two more symbols to distinguish positive and negative: + and -3Unsigned Binary Integers3-bits5-bits8-bits0000000000000000010010000100000001201000010000000103011000110000001141000010000000100Y = “abc” = a.22 + b.21 + c.20N = number of bitsRange is:0  i ((((13 - 1)/2)/2 - 1)/2 - 1) = 0 => (01101)2Leading zeros do not affect the value of a positive binary number, and leading ones do not affect the value of a negative number (in the 2’s complement representation). So: 01101 = 00001101 = 13 and 11011 = 11111011 = -58Manipulating Binary numbers - 2Binary addition simply consists of applying, to each column in the sum, the rules: 0 + 0 = 0 1 + 0 = 0 + 1 = 1 1 + 1 = 10With 2’s complement representation, this works for both positive and negative integers so long as both numbers being added are represented with the same number of bits. e.g. to add the number 13 => 00001101 (8 bits) to -5 => 1011 (4 bits): we have to sign-extend (SEXT) the representation of -5 to 8 bits: 00001101 11111011 00001000 => 8 (as expected!)9Manipulating Binary numbers - 3OverflowIf we add the two (2’s complement) 4 bit numbers representing 7 and 5 we get : 0111 0101 1010 which corresponds to -6 !! We have overflowed the number of bits available, and the result is invalid.In general, if the sum of two positive numbers produces a negative result, or if the sum of two negative numbers produces a positive result, an overflow has occurred, and the result is invalid.10Floating-Point numbers - 1Normalized fractionSkip all 0’s to the right of the binary pointSkip the leading 1 (hidden bit).Biased exponentRepresent all exponent values as positive (unsigned) integersMakes comparison of values easier (why?)sexponentfraction18 bits23 bitsN = (-1)s x 1.fraction x 2(exponent – 127)11Floating-Point numbers - 2Values represented by convention:Infinity (+ and -): exponent = 255 and fraction = 0NaN (not a number): exponent = 255 and fraction  0Zero (0): exponent = 0 and fraction = 0 (note: exponent = 0 => fraction is de-normalized)Double precision floating pointsexponentfraction111 bits52 bitsN = (-1)s x 1.fraction x 2(exponent – 1023)12Other Data TypesOther number representationsHexadecimal, octalBCD, EBCDIC Text representationsASCII: uses 7 bits to represent main Western characters & symbols, plus several “control codes”Unicode: 16 bit superset of ASCII providing representation of many different alphabets and specialized symbol sets.13Hexadecimal RepresentationBase 16 (hexadecimal)More a convenience for us humans than a true computer data type0 to 9 represented as such10, 11, 12, 13, 14, 15 represented by A, B, C, D, E, F16 = 24: i.e. every hexadecimal digit can be represented by a 4-bit binary (unsigned) and vice-versa.Example14Another use for bits: LogicBeyond numberslogical variables can be true or false, on or off, etc., and so are readily represented by the binary system.A logical variable A can take the values false = 0 or true = 1 only.The manipulation of logical variables is known as Boolean Algebra, and has its own set of operations - which are not to be confused with the arithmetical operations of the previous section.The basic operations: NOT, AND, OR15Basic Logic OperationsEquivalent NotationsNot A = A’ = AA and B = A.B = AB = A intersection BA or B = A+B = AB = A union BANDABA.B000010100111ORABA+B000011101111NOTAA'0110Truth Tables of Basic Operations16More Logic OperationsExclusive OR (XOR): either or B is 1, not bothAB = A.B’ + A’.BXORABAB000011101110XOR and XNORXNORAB(AB)’00101010011117

Các file đính kèm theo tài liệu này:

  • pptnajjar_chap2_7251.ppt