121 lec delimited

Upload: jonathanaramirez

Post on 05-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 121 Lec Delimited

    1/96

    Information SystemsFundamentals II

    1IS 121: Information Systems Fundamentals II

  • 7/31/2019 121 Lec Delimited

    2/96

    Data representations and encryptions;

    Basic logic used in programming.

    2IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

  • 7/31/2019 121 Lec Delimited

    3/96

    Objectives

    Understanding a computers basic data unitssuch as binary numbers, bits, bytes, words, etc.and their conversions from and to octal, decimal,and hexadecimal digits

    Understanding basic concepts of computerinternal data representation, focusing onnumeric data, character codes etc

    Understanding proposition calculus and logical

    operations

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 3

  • 7/31/2019 121 Lec Delimited

    4/96

    Some Terminology

    Data representation unit and processing unit

    1. Binary Digits (Bits) Two levels of status in computers electronic circuits

    Whether the electric current passes through it or not Whether the voltage is high or low

    1 digit of the binary system represented by 1 or 0

    Smallest unit that represents data inside the computer

    1 bit can represent 2 values of data,0

    or1

    2 bits can represent 4 different values

    00, 01, 10, 11

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 4

  • 7/31/2019 121 Lec Delimited

    5/96

    (or Column)

    (or Row)

    (or

    Table)

  • 7/31/2019 121 Lec Delimited

    6/96

    Bit representation

    Switches Open (0) or closed (1)

    Current Not flowing (0) or flowing (1)

    Lights Off (0) or on (1)

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 6

  • 7/31/2019 121 Lec Delimited

    7/96

    2. Bytes A byte is a unit that represents with 8 bits 1

    character or number, 1 byte = 8 bits

    E.g. 00000000, 00000010, etc. 1 bit can be represented in 2 ways, i.e.

    combination of 8 bit patterns into 1 byte enablesthe representation of 28 = 256 types ofinformation

    Using a 1-byte word, 256 different characters canbe represented sufficient for most Westerncharacter sets

    Numeric Conversion

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 7

  • 7/31/2019 121 Lec Delimited

    8/96

    2. Bytes However, the number of kanji (Chinese

    characters) amounts to thousands of differentcharacters, hence a 1-byte word system is

    insufficient Two bytes are connected to obtain 16 bits, 216 =

    65,536 A 2-byte word

    Numeric Conversion

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 8

  • 7/31/2019 121 Lec Delimited

    9/96

    3. Word The smallest unit that represents data inside a

    computer

    Increase operation speed

    Numeric Conversion

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 9

  • 7/31/2019 121 Lec Delimited

    10/96

    4. Number systems Binary system is used to simplify the structure of

    electronic circuits that make up a computer

    Hexadecimal number is a numeric value

    represented by 16 numerals from 0 to 15 toease the representation of binary numbers for

    humans computers are capable of only usingbinary numbers

    Numeric Conversion

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 10

  • 7/31/2019 121 Lec Delimited

    11/96

    Numeric Systems

    Also known as Base Systems or RadixSystems

    Available digits: Decimal system (base 10) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

    Binary system (base 2) 0, 1

    Octal system (base 8)

    0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal (base 16) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F where A=10,B=11,C=12,D=13,E=14,F=15

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 11

  • 7/31/2019 121 Lec Delimited

    12/96

    Numeric DataRepresentation

    The true value of numbers arethe same

    The representation of numbersvary

    Decimal

    Binary

    Octal

    Hexadecimal

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

  • 7/31/2019 121 Lec Delimited

    13/96

    Numeric data representation

    DECIMAL number

    (Radix/Base = 10)

    2 1 9 9 8

    Weight 104 103 102 101 100

    Value 2*104 2*103 2*102 9*101 8*100

    Final (true) value 20000 + 1000 + 900 + 90 + 8 = 2199810

    BINARY number

    (Radix/Base = 2)

    1 1 0 0 1

    Weight 24 23 22 21 20

    Value 1*24 1*23 0*22 0*21 0*20

    Final (true) value 16 + 8 + 0 + 0 + 1 = 252

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 13

  • 7/31/2019 121 Lec Delimited

    14/96

    Numeric data representation

    OCTAL number

    (Radix/Base = 8)

    2 1 7 7 2

    Weight

    Value

    Final (true) value

    HEXA number

    (Radix/Base = 16)

    A 2 5 7 C

    Weight

    Value

    Final (true) value

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2 14

  • 7/31/2019 121 Lec Delimited

    15/96

    Binary Arithmetic

    Addition and subtraction of binary numbers Addition

    0 + 0 = 0 (or 010) 0 + 1 = 1 (or 110)

    1 + 0 = 1 (or 110) 1 + 1 = 10 (or 210)

    Subtraction 0 0 = 0 0 1 = -1

    1 0 = 1 1 1 = 0

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    15

  • 7/31/2019 121 Lec Delimited

    16/96

    Binary Addition

    Result = 1001102

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    16

  • 7/31/2019 121 Lec Delimited

    17/96

    Binary Subtraction

    Result = 10102

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    17

  • 7/31/2019 121 Lec Delimited

    18/96

    4. Addition and subtraction of hexadecimalnumbers Addition

    Performed starting at the lowest (first from the

    right) digit A carry to the upper digit is performed when the

    result is higher than 16

    Subtraction

    Performed starting at the lowest (first from theright) digit

    A borrow from the upper digit is performed whenthe result is negative

    Hexadecimal arithmetic

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    18

  • 7/31/2019 121 Lec Delimited

    19/96

    Hexadecimal Addition

    First column from rightD + 7 = (In the decimal system: 13 + 7 = 20) = 16 (carried 1) + 4The sum of the first column is 4 and 1 is carried to the second column.

    Second column from right1 + 8 + 1 = (In the decimal system: 10) = A

    Carried from the first column Third column from right

    A + B = (In the decimal system: 10 + 11 = 21) = 16 (carried 1) + 5The sum of the third column is 5 and 1 is carried to the fourth column.

    The result is (15A4)16.

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    19

  • 7/31/2019 121 Lec Delimited

    20/96

    Hexadecimal Subtraction

    First column from rightSince 3 4 =1, a borrow is performed from D in the second digit

    (D becomes C).

    16 (borrowed 1) + 3 4 = F (In the decimal system: 19 4 = 15)

    Second column from right

    C 7 = 5 (In the decimal system: 12 7 = 5) Third column

    6 1 = 5

    The result is (55F)16.

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    20

  • 7/31/2019 121 Lec Delimited

    21/96

    Exercises

    Compute the following

    a) 2710 + 1510b) 110112 + 11112c) 338 + 178

    d) 1B16 + F16

    Compute the following

    a) 5010 2210

    b) 1100102 - 101102c) 628 268d) 3216 - 1616

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    21

  • 7/31/2019 121 Lec Delimited

    22/96

    Representation of numeric data

    1. Radix and weight

    Decimal numbersweight and its meaning

    10 is called Radix

    upper right of 10 (in this example, 4) is called exponent

    Binary digits weight and its meaning

    2. Auxiliary units and power representation

    Used to represent big, small amounts, and exponent towhich the radix is raised

    Numeric data representation

    300010 = 3 * 103

    Radix/Base

    Exponent

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    22

  • 7/31/2019 121 Lec Delimited

    23/96

    In order to process numeric values in a computer, decimalnumbers are converted into binary or hexadecimal numbers

    However, since we ordinarily use decimal numbers, it would bedifficult to understand the meaning of the result of a process if itwere represented by binary or hexadecimal numbers.

    This operation is called radix conversion The following radix/base conversion techniques will be

    discussed:1. Decimal to Binary2. Binary to Decimal

    3. Binary to Hexadecimal4. Hexadecimal to Binary5. Octal to Binary6. Binary to Octal

    Radix/Base Conversion

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    23

  • 7/31/2019 121 Lec Delimited

    24/96

    1. Decimal to Binary (Integer)

    1. Decimal integer is divided into 2

    2. The quotient and remainder are obtained

    3. The quotient is divided into 2 again until thequotient becomes 0

    4. The binary value is obtained by placing theremainder(s) in reverse order

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    24

  • 7/31/2019 121 Lec Delimited

    25/96

    1. Decimal to Binary (Integer)

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    25

  • 7/31/2019 121 Lec Delimited

    26/96

    1. Decimal to Binary (Fraction)

    Decimal fraction is multiplied by 2

    Resulting integer portion is extracted (always be 0 or 1)

    Resulting fraction portion is multiplied by 2

    Operation is repeated until the fraction portion becomes 0

    When decimal fractions are converted into binaryfractions, most of the times, the conversion is notfinished, since no matter how many times the fractionportion is multiplied by 2, it will not become 0. Most

    decimal fractions become infinite binary fractions.

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    26

  • 7/31/2019 121 Lec Delimited

    27/96

    1. Decimal to Binary (Fraction)

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    27

  • 7/31/2019 121 Lec Delimited

    28/96

    2. Binary to Decimal (Integer)

    Performed by adding up the weights of each ofthe digits of the binary bit string

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    28

  • 7/31/2019 121 Lec Delimited

    29/96

    2. Binary to Decimal (Fraction)

    Same technique as for binary integers.

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    29

  • 7/31/2019 121 Lec Delimited

    30/96

    3. Binary to Hexadecimal

    4-bit binary strings are equivalent to 1hexadecimal digit

    The binary number is divided into groups of 4

    digits starting from the decimal point In the event that there is a bit string with less

    than 4 digits, the necessary number of 0s isadded and the string is considered as a 4-bitstring

    IT 121: Information Technology Fundamentals 2ICS 121: Introduction to Computer Science 2

    30

  • 7/31/2019 121 Lec Delimited

    31/96

    3. Binary to Hexadecimal(Integer)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    31

  • 7/31/2019 121 Lec Delimited

    32/96

    3. Binary to Hexadecimal(Fraction)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    32

  • 7/31/2019 121 Lec Delimited

    33/96

    4. Hexadecimal to Binary(Integer)

    1 digit of the hexadecimal number isrepresented with a 4-digit binary number

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    33

  • 7/31/2019 121 Lec Delimited

    34/96

    4. Hexadecimal to Binary(Fraction)

    Same technique as per integer

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    34

  • 7/31/2019 121 Lec Delimited

    35/96

    5. Octal to Binary

    Convert 1038 to its binary form

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    35

  • 7/31/2019 121 Lec Delimited

    36/96

    6. Binary to Octal

    Convert 10000112 to Octal

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    36

  • 7/31/2019 121 Lec Delimited

    37/96

    Exercises

    Convert into binary, octal and hexa

    a) 2710b) 1510

    c) 50.2210 Convert into decimal

    a) 110112b) 338c) 1B.F16

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    37

  • 7/31/2019 121 Lec Delimited

    38/96

    Octal-Binary Conversions

    Binary to/from Octal conversion Conversion of binary to/from octal (whole numbers) Conversion of octal fractions

    In decimal, 26.9210 = (2 * 101) + (6 * 100) + (9 * 10-1) + (2 * 10-2)

    0.48 means 4 * 8-1 = (4/8) 10 = 10 = 0.510

    0.2118 means (2 * 8-1) + (1 * 8-2) + (1 * 8-3)

    Conversion of binary fractions Binary fractions can be converted in a similar manner to octal as that

    of octal fractions The number can then be converted to decimal by adding up the

    whole numbers and convert the fractions to decimals

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    38

  • 7/31/2019 121 Lec Delimited

    39/96

    Try thisA. What number does the next digit position

    represent in the hexadecimal system?

    B. Use the answer to evaluate the decimalequivalent of 2A9D16

    C. What is the highest decimal number which maybe represented by four hexadecimal digits?

    D. What is the highest decimal number which maybe represented by four octal digits?

    Quiz

    ? ? 256 16 1

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    39

  • 7/31/2019 121 Lec Delimited

    40/96

    Numeric Presentation

    Data

    Decimal

    Numbers

    Unpacked Decimal

    Fixed Point (Integers)

    CharacterData

    Packed Decimal

    Floating Point (Real Numbers)Numeric

    Data

    BinaryNumbers

    Representedusing decimalarithmetic

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    40

  • 7/31/2019 121 Lec Delimited

    41/96

    Decimal digit representation

    Binary coded decimal

    Unpacked decimal format

    Packed decimal format

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    41

  • 7/31/2019 121 Lec Delimited

    42/96

    Decimal digit representation

    o Binary-coded decimal (BCD) code Uses 4-bit binary digits (correspond to numbers 0 to 9 of

    decimal system)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    42

  • 7/31/2019 121 Lec Delimited

    43/96

    Decimal digit representation

    BCD code

    Example:

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    43

  • 7/31/2019 121 Lec Delimited

    44/96

    Decimal digit representation

    Unpacked decimal format

    Uses 1 byte for each digit of decimal number

    Represents values from 0 to 9 in least significant 4 bits of 1byte and in most significant 4 bits (zone bits)

    Half of a byte is used (excepting the least significant byte)where the least significant half-byte is used to store the sign

    1100 = +ve

    1101 = -ve

    Waste of resources (eliminated by packed decimal format)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    44

  • 7/31/2019 121 Lec Delimited

    45/96

    Decimal digit representation Unpacked decimal format

    +78910 = F7F8C916

    -78910 = F7F8D916

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    45

  • 7/31/2019 121 Lec Delimited

    46/96

    Decimal digit representation

    o Packed decimal format 1 byte represents a numeric value of 2 digits

    the least significant 4 bits represent the sign

    bit pattern for the sign is the same as per unpackeddecimal format

    +78910 = 789C16

    -78910 = 789D16IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    46

  • 7/31/2019 121 Lec Delimited

    47/96

    Questions

    A) Represent 7089310 in Unpacked Decimal Format in Packed Decimal Format

    B) Represent 789310 in Unpacked Decimal Format in Packed Decimal Format

    C) F3F9C116 is represented in standard UnpackedDecimal Format What is its equivalent in decimal? Possible solution?

    D) 3F9C16 is represented in standard Packed DecimalFormat What is its equivalent in decimal? Possible solution?

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    47

  • 7/31/2019 121 Lec Delimited

    48/96

    Decimal digit representation

    o Packed decimal format versus Unpacked decimalformat

    A numeric value can be represented by fewer bytes

    The conversion into the binary system is easy

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    48

  • 7/31/2019 121 Lec Delimited

    49/96

    Representation of negative integers Absolute value representation

    0 for positive, 1 for negative

    Complement representation Decimal complement

    9s complement

    10s complement

    Binary complement

    1s complement 2s complement

    Binary Representation

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    49

  • 7/31/2019 121 Lec Delimited

    50/96

    Binary Representation

    Absolute value representation Examples

    (00001100)2 = (+12)10

    (10001100)2 = (-12)10 Issues

    (00000000)2 = +0

    (10000000)2 = -0

    Range of values (assumption: 7-bit absolute value representationused) -63 to +63 equivalent to(26-1) to +(26-1)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    50

  • 7/31/2019 121 Lec Delimited

    51/96

    Binary Representation

    Complementrepresentation ofnegative numbers

    Decimal complement The subtraction of

    each of the digits of anumeric value from the

    complement

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    51

  • 7/31/2019 121 Lec Delimited

    52/96

    Binary Representation

    Binary complement

    1s complement of a given numeric value is the result of thesubtraction of each of the digits of this numeric value from 1,

    as a result, all the 0 and 1 bits of the original bit string areswitched.

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    52

  • 7/31/2019 121 Lec Delimited

    53/96

    Binary Representation

    Binary complement

    2s complement is 1s complement + 1

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    53

  • 7/31/2019 121 Lec Delimited

    54/96

    Binary Representation

    1s complement and 2s complementrepresentation of negative numbers

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    54

  • 7/31/2019 121 Lec Delimited

    55/96

    Binary Representation

    Advantages of 2s complement Less complicated (only one zero value)

    Range of values to be represented is wider Subtractions can be performed with addition circuits, simplifying

    hardware structure

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    55

  • 7/31/2019 121 Lec Delimited

    56/96

    Binary Representation

    1s complement and 2s complementrepresentation of negative integers

    range of represented numeric values when n-bit binarynumber is represented by adopting the 1s complement

    method:-(2n-1 1) to (2n-1 1)

    range of represented numeric values when n-bit binary

    number is represented by adopting the 2s complementmethod:

    -(2n-1) to (2n-1 1)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    56

  • 7/31/2019 121 Lec Delimited

    57/96

    Binary Representation

    Addition circuits only

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    57

    Binary Representation (Fixed

  • 7/31/2019 121 Lec Delimited

    58/96

    Binary Representation (FixedPoint)

    Fixed point

    Integer representation

    Fixed point is a data representation format used mainlywhen integer type data is processed

    One word is represented in a fixed length (e.g. 16 bits and32 bits)

    Overflow problem when attempt is made to represent anumeric value that exceeds the fixed length allocated

    Fraction representation Decimal point is considered to be immediately preceded by

    the sign bit

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    58

    Binary Representation (Fixed

  • 7/31/2019 121 Lec Delimited

    59/96

    Binary Representation (FixedPoint)

    Fixed point

    Integer representation

    Range of values

    -(2n-1) to (2n-1 1)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    59

    Binary Presentation (Fixed

  • 7/31/2019 121 Lec Delimited

    60/96

    Binary Presentation (FixedPoint)

    Fixed point

    Fraction representation

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    60

    Binary Representation (Floating

  • 7/31/2019 121 Lec Delimited

    61/96

    Binary Representation (FloatingPoint)

    Floating point

    Used to represent realnumber type data

    Used to represent

    extremely large orsmall size of data

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    61

  • 7/31/2019 121 Lec Delimited

    62/96

    Bit Shift Operations

    Using bit shifts, the multiplication and division of numericvalues can be easily performed

    Shifting a binary digit 1 bit to the left, its value is doubled.

    When a binary number is shifted nbits to the left, its former valueis increased 2n times

    When a binary number is shifted nbits to the right, its formervalue decreases 2-n times (divided by 2n)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    62

  • 7/31/2019 121 Lec Delimited

    63/96

    Arithmetic Shift

    To calculate numeric values in the fixed point format using 2scomplement representation

    Rules Sign bit is not shifted Bit shifted out is lost Bit to be filled into the bit position is vacated as a result of the shift

    is For left shifts, insert 0 For right shifts, insert the same bit as the sign bit

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    63

  • 7/31/2019 121 Lec Delimited

    64/96

    Logical Shift

    To change the bit position

    Rules

    Sign bit is also shifted (moved)

    Bit shifted out is lost

    Bit to be filled into the bit position vacated as aresult of the shift is 0.

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    64

  • 7/31/2019 121 Lec Delimited

    65/96

    Bit Shifts

    (-16)2 to be shifted 2 bits to the right Arithmetic Shift

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    65

  • 7/31/2019 121 Lec Delimited

    66/96

    Bit Shifts

    Logical Shift

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    66

  • 7/31/2019 121 Lec Delimited

    67/96

    Operation and Precision

    Precision of the numeric valuepresentationo The precision of a number is the range of its

    erroro High precision = small error

    o Single precision Range of numeric values presentable with 16 bits

    (in the case of an integer without a sign) Minimum value = (0000 0000 0000 0000)2 = 0

    Maximum value = (1111 1111 1111 1111)2 = 65,535

    (values higher than 65,535 cannot be represented)

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    67

  • 7/31/2019 121 Lec Delimited

    68/96

    Range of numeric values presentable with 16 bits(in the case of a fraction without a sign)

    Minimum value = (0000 0000 0000 0001)2 = 2-16 =

    0.0000152587890625000 Maximum value = (1111 1111 1111 1111)2 = 1 2

    16 =0.9999847412109370000

    (values lower than 0.00001525878, and values higherthan 0.99984741210937 cannot be represented)

    Operation and Precision

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    68

  • 7/31/2019 121 Lec Delimited

    69/96

    o Double precision

    Number of digits is increased to widen the rangeof represented numeric values

    Represent 1 numeric value with 2 words

    1 numeric value presentable with 32 bits (in the

    case of an integer without a sign)

    Minimum value = (0000 0000 0000 0000 0000 00000000 0000)2 = 0

    Maximum value = (1111 1111 1111 1111 1111 11111111 1111)2 = 4,294,967,295

    (values up to 4,294,967,295 can be represented)

    Operation and Precision

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    69

  • 7/31/2019 121 Lec Delimited

    70/96

    Range of numeric values presentable with 16 bits (inthe case of a fraction without a sign)

    Minimum value = (0000 0000 0000 0000 0000 0000 00000001)2 = 2

    -32 = 0.00000000023283064365387

    Maximum value = (1111 1111 1111 1111 1111 11111111 1111)2 = 1 232 = 0.99999999976716900000000

    Operation and Precision

    IT 121: Information Technology Fundamentals 2

    ICS 121: Introduction to Computer Science 2

    70

  • 7/31/2019 121 Lec Delimited

    71/96

    Operation precisiono Precision of fixed point representation

    Range of presentable numeric values depends on the computerhardware (number of bits in one word)

    Range of represented numeric values differs depending on the numberof bits in one word

    Step size of the integer part is always 1 (regardless of number of bits),and only the maximum value changes

    In the fraction part, the smaller the step size becomes, the error is alsoreduced

    o Precision and underflow Overflow and underflow

    Overflow occurs when product is higher than the maximum value that can berepresented with the exponent portion (Maximum absolute value < Overflow)

    Underflow occurs when product is lower than the minimum absolute value (0