1. Trang chủ
  2. » Giáo án - Bài giảng

Kĩ Thuật Vi Xử Lý Numerical_Representation

36 6 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 36
Dung lượng 0,93 MB

Nội dung

Binary Digital System Data Types Conversions Binary Arithmetic Overflow Fixed Point Floating Point Hexadecimal Numbers ASCII Characters

Numerical Representation Review          Binary Digital System Data Types Conversions Binary Arithmetic Overflow Fixed Point Floating Point Hexadecimal Numbers ASCII Characters Numerical Representation Digital Binary System What are Decimal Numbers?  “Decimal” means that we have ten digits to use in our representation of numbers     What is 3,546?    Symbols through Positional notation Most widely used by modern civilizations thousands + hundreds + tens + ones 3,54610 = 3× 103 + 5× 102 + 4× 101 + 6× 100 How about negative numbers?  Use two more symbols to distinguish positive from negative numbers, namely, + and - Numerical Representation Digital Binary System What are Binary Numbers?  “Binary” means that we have two digits to use in our representation of numbers     What is the decimal value of binary 1011?    Symbols and Positional notation More adaptable for computers eights + fours + twos + ones 10112 = 1× 23 + 0× 22 + 1× 21 + 1× 20 How about negative numbers?   We don’t want to add additional symbols So… Numerical Representation Digital Binary System Binary Digital System     Binary (base 2) because there are two states, and Digital because there are a finite number of symbols Basic unit of information is the binary digit, or bit Bit values are represented by various physical means      Voltages Residual magnetism Light Polarization Values with more than two states require multiple bits    A collection of bits has possible states: 00, 01, 10, 11 A collection of bits has possible states: 000, 001, 010, 011, 100, 101, 110, 111 A collection of n bits has 2n possible states Numerical Representation Digital Binary System Electronic Representation of a Bit  Relies only on approximate physical values    A logical ‘1’ is a relatively high voltage (2.4V - 5V) A logical ‘0’ is a relatively low voltage (0V - 1V) Analog processing relies on exact values which are affected by temperature, age, etc    Analog values are never quite the same Each time you play a vinyl album, it will sound a bit different CDs sound the same no matter how many times you play them Numerical Representation Digital Binary System The Power of the Bit…  Bits rely on approximate physical values that are not affected by age, temperature, etc    By using groups of bits, we can achieve high precision       Music that never degrades Pictures that never get dusty or scratched bits => each bit pattern represents 1/256 16 bits => each bit pattern represents 1/65,536 32 bits => each bit pattern represents 1/4,294,967,296 64 bits => each bit pattern represents 1/18,446,744,073,709,550,000 Disadvantage: bits only represent discrete values Digital = Discrete Numerical Representation Digital Binary System Binary Nomenclature    Binary Digit: or (bit) LSB (least significant bit): The rightmost bit MSB (most significant bit): The leftmost bit Name (Symbol) Value Binary Byte (B) 100 20 byte Kilobyte (kB) 103 210 1024 bytes Megabyte (MB) 105 220 1,048,576 bytes Gigabyte (GB) 109 230 1,073,741,824 bytes Terabyte (TB) 1012 240 1,099,511,627,776 bytes Petabyte (PB) 1015 250 1,125,899,906,842,624 bytes Exabyte (EB) 1018 260 1,152,921,504,606,846,976 bytes Zettabyte (ZB) 1021 270 1,180,591,620,717,411,303,424 bytes Yotabyte (YB) 1024 280 1,208,925,819,614,629,174,706,176 bytes Numerical Representation Data Types What Kinds of Data?  All kinds…         Data type:   Numbers – signed, unsigned, integers, floating point, complex, rational, irrational, … Text – characters, strings, … Images – pixels, colors, shapes, … Sound – pitch, amplitude, … Logical – true / false, open / closed, on / off, … Instructions – programs, … … representation and operations within the computer We’ll start with numbers… Numerical Representation Data Types Some Important Data Types  Unsigned integers    Signed integers     Bounded negative, zero, positive numbers w/fraction -2.5, 0.0, 100.125, … Floating point numbers    Negative, zero, positive numbers …, -3, -2, -1, 0, 1, 2, 3, … Fixed point numbers   Only non-negative numbers 0, 1, 2, 3, 4, … Unbounded negative, zero, positive numbers w/fraction PI = 3.14159 x 100 Characters   8-bit, unsigned integers ‘0’, ‘1’, ‘2’, … , ‘a’, ‘b’, ‘c’, … , ‘A’, ‘B’, ‘C’, … , ‘@’, ‘#’, Numerical Representation Data Types Unsigned Integers  Weighted positional notation  “3” is worth 300, because of its position, while “9” is only worth most significant 329 102 101 100  101 22 3x100 + 2x10 + 9x1 = 329 least significant 21 20 1x4 + 0x2 + 1x1 = What these unsigned binary numbers represent? 0000 0110 1111 1010 0001 1000 Numerical Representation 0111 1100 1011 1001 10 Overflow 2’s Complement Overflow    Overflow = the result doesn’t fit in the capacity of the representation ALU’s are designed to detect overflow It’s really quite simple   if the carry in to the most significant position (MSB) is different from the carry out from the most significant position (MSB), then overflow occurred Generally, overflows represented in CPU status bit Numerical Representation 22 Conversions Decimal to Binary Conversion  Continually divide the number by and track the remainders 43 21 R 10 R R0 2 R1 R0 R1  101011 × 25 + × 24 + × 23 + × 22 + × 21 + × 20 32 + + + + + = 43 For negative numbers, above for positive number and negate result Numerical Representation 23 Conversions Decimal to Binary Conversion Number Binary Value 0101 0110 123 01111011 35 00100011 -35 11011101 1007 01111101111 Numerical Representation 24 Word Size Word Sizes  Word size is the natural unit of data used by a particular computer design and usually refers to:       Size of registers Amount of data transferred to/from memory in single operation Largest possible address Number of bits processed in a single operation Size of smallest instruction Every computer has a base word size   Intel Pentium machines are 32/64 bit MPS430 is 16-bits Numerical Representation 25 Fixed Point Fixed Point Numbers  Bounded negative, zero, positive numbers w/fraction     Fractions are created by dividing a binary number into an integral and fractional part The program is responsible for knowing the position of the “decimal point” Signed or un-signed Example: -29 28 27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5 2-6 0 0 0 0 1 0 0 = 1.5 Whole or integral Part Decimal Numerical Representation Point Fractional Part 26 Fixed Point Fixed Point Numbers 0 0 0 0 1 0 0 Whole part Fractional part  With a fixed-point fractional part, we can have 5/2 = 2.5  The more bits you use in your fractional part, the more accuracy you will have  Accuracy is 2^-(fraction bits)  For example, if we have bits in our fractional part (like the above example), our accuracy is 2^-6 = 0.015625 In other words, every bit is equal to 0.015625 Numerical Representation 27 Fixed Point Fixed Point Arithmetic  Fixed point addition: 0 0 0 0 1 0 0 + Adding 2.5 + 2.5 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 =5  Without fixed point math the result would have been due to the truncation of the integer division Numerical Representation 28 Floating Point Floating Point Numbers  Unbounded negative, zero, positive numbers w/fraction   Binary scientific notation 32 / 64 bit floating point s exponent 23 mantissa N = -1s × 1.fraction × 2(exponent – 127)    Exponent is biased by 127 Implied leading in mantissa Zero represented by all 0’s Numerical Representation 29 Floating Point Floating Point Numbers  Why the leading implied 1?  Always normalize after an operation    shift mantissa until leading digit is a can assume it is always there, so don’t store it Why the biased exponent?  To avoid signed exponent representations s exponent 23 mantissa N = -1s × 1.fraction × 2(exponent – 127) Numerical Representation 30 Floating Point Floating Point Numbers  What does this represent? 10000000 10000000000000000000000 Positive number Exponent is 128 which means the real exponent is Mantissa is to be interpreted as 1.1 This is 20 + 2-1 = + 1/2 = 1.5 The final number is 1.5 x 21 = Numerical Representation 31 Floating Point Floating Point Numbers  What does this represent? 10000001 10101000000000000000000 Negative number Exponent is 129 which means the real exponent is Mantissa is to be interpreted as 1.10101 This is 20 + 2-1 + 2-3 + 2-5 = + 1/2 + 1/8 + 1/32 = 1.65625 The final number is -1.65625 x 22 = -6.625 Numerical Representation 32 Quiz Quiz What is the decimal equivalent of the following signed, 16-bit (8 bit fraction), fixed point number? -27 26 25 24 23 22 21 20 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 0 1 1 1 0 Whole or integral Part Fractional Part 00010111 10110010 What is the decimal equivalent of this floating point number? s exponent 23 mantissa N = -1s × 1.fraction × 2(exponent – 127) 10000011 11000000000000000000000 Numerical Representation 33 Hexadecimal Hexadecimal Notation   Binary is hard to read and write by hand Hexadecimal is a common alternative  16 digits are 0123456789ABCDEF 0100 1101 1011 1010 0111 1110 1110 0101 1000 1010 1110 1010 1111 1101 1111 0101 Separate binary code into groups of bits (starting from the right) Translate each group into a single hex digit = = = = 0x478F 0xDEAD 0xBEEF 0xA5A5 0x is a common prefix for writing numbers which means hexadecimal Numerical Representation Binary Hex 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 A B C D E F 34 ASCII Characters ASCII Codes  The American Standard Code for Information Interchange (ASCII) is a character-encoding scheme based on the ordering of the English alphabet     Represent text in computers 8-bit, unsigned integers 1st 32 codes unprintable Questions     What is relationship between a decimal digit (0, 1, …) and its ASCII code? What is the difference between an upper-case letter ('A', 'B', …) and its lower-case equivalent ('a', 'b', …)? Given two ASCII characters, how we tell which comes first in alphabetical order? Are 128/256 characters enough? (http://www.unicode.org/) Numerical Representation 35 ASCII Characters ASCII Characters 0 f NUL DLE SP @ P ` p SOH DC1 ! A Q a q STX DC2 “ B R b r ETX DC3 # C S c s EOT DC4 $ D T d t ENQ NAK % E U e u ACK SYN & F V f v BEL ETB ‘ G W g w BS CAN ( H X h x HT EM ) I Y i y a LF SUB * : J Z j z b VT ESC + ; K [ k { c FF FS , < L \ l | d CR GS - = M ] m } e SO RS > N ^ n ~ f SI US / ? O _ o DEL Numerical Representation 8-9 a- More More controls symbol s 36

Ngày đăng: 20/02/2022, 15:08

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN

w