binary representation and computer...

18
Binary Representation and Computer Arithmetic The decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D. 400. Since it involved the use of fingers and thumbs, it was natural that this system would have 10 digits. The system found its way to all the Arab countries by A.D. 800, where it was named the Arabic number system, and from there it was eventually adopted by nearly all the European countries by A.D. 1200, where it was called the decimal number system. The key feature that distinguishes one number system from another is the number system's base or radix. This base indicates the number of digits that will be used. The decimal number system, for example, is a base 10 number system which means that it uses 10 digits (0 to 9) to communicate information about an amount. A subscript is something included after a number when different number systems are being used to indicate the base of the number. For example 5327 would represent a number in base 7 (using the digits 0 to 6) number system. 1100 10 and 1100 2 are two numbers which contain the same digits but which are written using different bases. The first number we recognize as one thousand one hundred in the decimal (base 10) number system. The second number is a number in the base 2 number system called the binary number system. The Decimal System This uses ten digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to represent numbers. Consider a decimal number, 847. This means eight hundreds, four tens plus seven. 847 = 8*100 + 4*10 + 7 The system has a base or radix of ten. This means that each digit in a decimal number is multiplied by ten raised to a power corresponding to its position. Thus 847 = 8 * 10 2 + 4 * 10 1 + 7 * 10 0 Fractional values can be represented in the same way. 472.83 = 4 * 10 2 + 7 * 10 1 + 2 * 10 0 + 8 * 10 -1 + 3 * 10 -2 The Binary System The binary system uses just two digits, 0 and 1, as it is easier for a computer to distinguish between two different voltage levels than ten. This means that it has a base of two. Each digit in a binary number is multiplied by two raised to a power corresponding to its position. 1011 = 1 * 2 3 + 0 * 2 2 + 1 * 2 1 + 1 * 2 0 = 1 * 8 + 0 * 4 + 1 * 2 + 1 = 11 When confusion is possible, we can show the base of a number by using a subscript. For example, 1011 2 = 11 10 Converting Decimal Numbers to Binary Numbers

Upload: lythuan

Post on 17-Apr-2018

219 views

Category:

Documents


3 download

TRANSCRIPT

  • Binary Representation and Computer Arithmetic

    The decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D. 400. Since it involved the use of fingers and thumbs, it was natural that this system would have 10 digits. The system found its way to all the Arab countries by A.D. 800, where it was named the Arabic number system, and from there it was eventually adopted by nearly all the European countries by A.D. 1200, where it was called the decimal number system.

    The key feature that distinguishes one number system from another is the number system's base or radix. This base indicates the number of digits that will be used. The decimal number system, for example, is a base 10 number system which means that it uses 10 digits (0 to 9) to communicate information about an amount. A subscript is something included after a number when different number systems are being used to indicate the base of the number. For example 5327 would represent a number in base 7 (using the digits 0 to 6) number system.

    110010 and 11002 are two numbers which contain the same digits but which are written using different bases. The first number we recognize as one thousand one hundred in the decimal (base 10) number system. The second number is a number in the base 2 number system called the binary number system.

    The Decimal System

    This uses ten digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) to represent numbers.Consider a decimal number, 847. This means eight hundreds, four tens plus seven. 847 = 8*100 + 4*10 + 7 The system has a base or radix of ten. This means that each digit in a decimal number is multiplied by ten raised to a power corresponding to its position. Thus 847 = 8 * 102 + 4 * 101 + 7 * 100 Fractional values can be represented in the same way. 472.83 = 4 * 102 + 7 * 101 + 2 * 100 + 8 * 10-1 + 3 * 10-2

    The Binary SystemThe binary system uses just two digits, 0 and 1, as it is easier for a computer to distinguish between two different voltage levels than ten. This means that it has a base of two. Each digit in a binary number is multiplied by two raised to a power corresponding to its position. 1011 = 1 * 23 + 0 * 22 + 1 * 21 + 1 * 20

    = 1 * 8 + 0 * 4 + 1 * 2 + 1 = 11 When confusion is possible, we can show the base of a number by using a subscript. For example, 10112 = 1110 Converting Decimal Numbers to Binary Numbers

  • To convert a decimal number to binary, we can also use repeated division and note the remainder after each division.

    Example 1.1.5 Convert 83710 to binary.

    83710 converted to a binary number: Division Remainder

    1 LSD

    0

    1

    0

    0

    0

    1

    0

    1

    1 MSD

    Note that the first remainder gives the LSD and the last remainder the MSD.

    Then, 83710 = 11 0100 01012 Check: 11 0100 01012 = 512 + 256 + 64 + 4 + 1 = 837

    Octal and Hexadecimal Notation

    Binary notation is extremely awkward for humans to use, so other notations are common. Decimal notation is of course easy for us to use, but has the disadvantage that conversion between decimal and binary is complicated.

    One system which is sometimes used is octal. This system uses the first eight digits of the decimal system to represent groups of three bits, and so is base 8. For example,

    1010112 = 053

  • The leading 0 before the number 53 is a common way to indicate an octal number.

    This has the disadvantage that three does not go into eight, and as we have seen the fundamental unit of information is a chunk of eight bits.

    Therefore, another commonly used notation is hexadecimal, or simply hex. This breaks the data into nybbles (nibbles) (four bit chunks), so each byte may be represented by two hex digits. Unfortunately, this makes hexadecimal notation base 16 (hence the name), and so we must use the first six letters of the alphabet as well as the ten digits of the decimal system. For example,

    101110102 = 0xBC

    The leading 0x before the number is a common way to indicate a hexadecimal number.

    Binary Arithmetic

    The basic rules for binary addition are listed in the table below.

    Rule 1 Rule 2 Rule 3 Rule 4 Rule 5

    0 + 0 0

    0 + 1 1

    1 + 0 1

    1 + 1 10

    1 1 + 1 11

    The basic rules for binary subtraction are listed in the table below.

    Rule 1 Rule 2 Rule 3 Rule 4

    0 - 0 0

    1 - 1 0

    1 - 0 1

    0 - 1 1

    ALL ABOUT INTEGER REPRESENTATION.-----------------------------------------------

    Computers operate on binary values (as a result of being built from transistors).

    There are different binary representations for integers possible qualifications: 1. Positive numbers only 2. Positive and negative numbers 3. Ease of human readability 4. Speed of computer operations

    There are 4 commonly known (1 not common) integer reprentations.All have been used at various times for various reasons. 1. Unsigned 2. Sign magnitude 3. One's complement 4. Two's complement 5. biased (not commonly known)

  • Virtually all modern computers operate based on 2's complement representation. Why? 1. Hardware is faster 2. Hardware is simpler (which makes it faster)

    UNSIGNED-------------

    The standard binary encoding already given

    Only positive values

    Range: 0 to 2**n - 1, for n bits

    Example: 4 bits, values 0 to 15 n=4, 2**4 -1 is 15

    Binary dec. hex binary decimal hex 0000 0 0 1000 8 8 0001 1 1 1001 9 9 0010 2 2 1010 10 a 0011 3 3 1011 11 b 0100 4 4 1100 12 c 0101 5 5 1101 13 d 0110 6 6 1110 14 e 0111 7 7 1111 15 f

    SIGN MAGNITUDE---------------------

    A human readable way of getting both positive and negative integers.The hardware that does arithmetic on sign magnitude integers is not fast, and it is more complex than the hardware that does arithmetic on 1's comp. and 2's comp. integers.

    Use 1 bit of integer to represent the sign of the integer

    Let sign bit of 0 be positive, 1 be negative.

    The rest of the integer is a magnitude, using same encoding as unsigned integers

    Example: 4 bits 0101 is 5

    1101 is -5

    To get the additive inverse of a number, just flip (not, invert, complement, negate) the sign bit.

    range: -(2**(n-1)) + 1 to 2**(n-1) -1 where n is the number of bits

    4 bits, -7 to +7 n=4, - 2**3 + 1 to 2**3 - 1 -8 + 1 to 8 - 1

  • Because of the sign bit, there are 2 representations for 0. This is a problem for hardware. . .

    0000 is 0, 1000 is 0 The computer must do all calculations such that they come out correctly and the same whichever representation is used.

    ONE's COMPLEMENT------------------------

    Historically important, and we use this representation to get 2's complement integers.

    Now, nobody builds machines that are based on 1's comp. integers. In the past, early computers built by Semour Cray (while at CDC) were based on 1's comp. integers.

    Positive integers use the same representation as unsigned. 00000 is 0 00111 is 7, etc.

    The formal way to determine the 1's complement in binary of a negative integer uses the following rule:

    Rule: The 1's complement in binary of a negative integer is obtained by subtracting its magnitude from 2n -1 where n is the number of bits used to store the integer in binary.

    ExampleStore the integer -36 in a byte in 1's complement form. Step 1: +3610 = 0010 01002 [convert the magnitude of the integer to binary] Step 2: 1111 1111 - 0010 0100 1101 1011 A byte contains 8 bits. Therefore, subtract 0010 0100 from 28 - 1 = 255. In binary 255 is1111 1111.However, we note the following:Using a byte, the 1's complement of +36 is 0010 0100Using a byte, the 1's complement of -36 is 1101 1011 If these representations are compared bit by bit, one can see that corresponding bits are inverted.

    Negation (finding an additive inverse) is done by taking a bitwise complement of the positive representation.

    COMPLEMENT. INVERT. NOT. FLIP. NEGATE. A logical operation done on a single bit

    The complement of 1 is 0. The complement of 0 is 1.

    -1 --> take +1, 00001 Complement each bit 11110

  • That is -1. Dont add or take away any bits.

    EXAMPLES: 11100 this must be a negative number. to find out which, find the additive inverse!

    00011 is +3 by sight, so 11100 must be -3

    Things to notice: 1. any negative number will have a 1 in the MSB. 2. There are 2 representations for 0,

    00000 and 11111.

    Converting from 1's Complement Notation to Decimal Notation

    Case 1: The MSB of the Byte is 0If a byte contains, for example, 0101 1001 which represents an integer stored in 1's complement form, we know that since the MSB = 0, this is a positive integer. The decimal integer value of the byte then is :

    0 1 0 1 1 0 0 1This 0 indicates the integer is positive

    64 16 8 1

    Therefore 0101 1001 which represent a binary number in 1's complement form is the decimal integer 64+16+8+1 = +89 Case 2: The MSB of the Byte is 1Add the Weight of all Bits Containing a 0Convert 1100 0110 to decimal.The MSB has value 1. Therefore, the integer is negative. Bits 5, 4, 3 and 0 have value 0. Therefore, the integer value is -(32 + 16 + 8 + 1) = -57. These steps are summarized in the following table:

    Binary Number in 1's Complement Notation

    1 1 0 0 0 1 1 0

    Weight of Bits Containing 0's

    This is the sign bit indicating the integer is negative

    32 16 8 1

    Therefore 1100 0110 which represents a binary number stored in 1's complement notation has decimal value -(32+16+8+1) = -57

    TWO's COMPLEMENT------------------------

  • Rule: To determine the 2's complement of a negative integer, determine the 1's complement and add 1.

    A variation on 1's complement that does NOT have 2 representations for 0. This makes the hardware that does arithmetic faster than for the other representations.

    A 3 bit example: Bit pattern: 100 101 110 111 000 001 010 011

    1's comp: -3 -2 -1 0 0 1 2 3

    2's comp.: -4 -3 -2 -1 0 1 2 3

    The negative values are all "slid" down by one, eliminating the extra zero representation.

    ExampleStore -27 in a byte using 2's complement notation. Steps 1 and 2 determine the 1's complement: Step 1: +27 in binary is 0001 1011. Step 2: Invert bits to yield 1110 0100. Then the 1's complement of -27 is 1110 0100. Step 3 is the additional step needed to find the 2's complement. Step 3: Add 1 to the 1's complement: 1110 0100 + 1 1110 0101 The 2's complement of -27 is 1110 0101.

    Finding the Decimal Integer Values of Positive and Negative Numbers Stored in Bytes in 2's Complement Form

    Case 1: The MSB of the Byte is 0If a byte contains the integer 0101 1001 in 2's complement form, we know that since the MSB = 0, this is a positive integer. The integer value of the byte then is 64 + 16 + 8 + 1 = +89 in decimal.Case 2: The MSB of the Byte is 1If a byte contains the integer 1101 1001 in 2'complement form, we know that since the MSB = 1, the integer is negative. The quickest way to find the decimal value for the integer is to add the weight of all columns containing a 0 and then add 1 to the result. The decimal integer value of 1101 1001 is

    Sign 64 32 16 8 4 2 11 1 0 1 1 0 0 1

  • 32 4 2 1101 1001 represents the integer -39 (Remember to add +1) Check: Write -39 in 2's complement byte form:

    Step Procedure Binary Answer in Byte Form

    1 Write +39 in binary 39 = 32 + 4 + 2 + 1 0010 0111

    2 Take the one's complement (invert the contents of the byte) 1101 1000

    3 Add 1 to the LSB + 1 The answer is the two's complement of -39. 1101 1001Therefore we store the integer -39 in a byte in 2's complement form as 1101 1001. This is the binary representation in 2's complement form that we were asked to convert to a decimal integer.

    BIASED REPRESENTATION-------------------------------

    An integer representation that skews the bit patterns so as to look just like unsigned but actually represents negative numbers.

    Examples: given 4 bits, we BIAS values by 2**3 (8)

    TRUE VALUE to be represented 3 Add in the bias +8

    ---- Unsigned value 11 So the bit pattern of 3 in 4-bit biased-8 representation will be 1011

    Going the other way, suppose we were given a biased-8 representation as 0110

    Unsigned 0110 represent 6 Subtract out the bias - 8

    ---- TRUE VALUE represented -2

    This representation allows operations on the biased numbers to be the same as for unsigned integers, but actually represents both positive and negative values.

    Choosing a bias: The bias chosen is most often based on the number of bits available for representing an integer. To get an approx. equal distribution of true values above and below 0, the bias should be 2 ** (n-1) or (2**(n-1)) - 1

    Two's Complement Arithmetic

    To perform mathematical functions, a computer's central processing unit, or CPU, contains several circuits, and one of these circuits is called the arithmetic-logic unit or ALU.

  • This unit is the number crunching circuit of every digital system, and, as its name implies, it can be controlled to perform arithmetic operations such as addition and subtraction or logic operations such as AND and OR

    A schematic of a simplified ALU is drawn below. You can see that the arithmetic-logic unit has two parallel inputs, one parallel output, and a set of function select control lines. If we wanted to add two integers, for example, the two integers would be retrieved, probably from memory, and would become inputs to the ALU. The function select part of the ALU would allow the decision to be made to add the numbers. The integers would be added [we shall describe how that addition occurs electronically in the next unit] most likely using 2's complement arithmetic. The sum of the integers would be the output from the ALU. The schematic and the explanation of addition are highly simplified. For example, the Intel Pentium 4 microprocessor has 6 integer execution units, and each of them has a 32-bit ALU.

    A schematic of a simplified ALU is drawn below. You can see that the arithmetic-logic unit has two parallel inputs, one parallel output, and a set of function select control lines. If we wanted to add two integers, for example, the two integers would be retrieved, probably from memory, and would become inputs to the ALU. The function select part of the ALU would allow the decision to be made to add the numbers. The integers would be added [we shall describe how that addition occurs electronically in the next unit] most likely using 2's complement arithmetic. The sum of the integers would be the output from the ALU. The schematic and the explanation of addition are highly simplified. For example, the Intel Pentium 4 microprocessor has 6 integer execution units, and each of them has a 32-bit ALU.

    The ALU has to be able to perform the four basic operations, namely addition, subtraction, multiplication and division. The fact that all numbers are stored in 2's complement form allows the ALU to use just one circuit for all four basic mathematical operations of addition, subtraction, multiplication and division. Multiplications can be thought of as repeated additions and divisions as repeated subtractions.

    Adding Positive Integers in 2's Complement Form

  • In the examples that follow, variables will be used to represent integers. This is consistent with what actually happens when you process numbers in a computer.

    When you write a computer program, you may include statements such as

    cost = 100 sales_tax = 7 total_cost = cost + sales_tax

    When the program is run, the variable names cost and sales_tax and their values would be stored in the computer's memory. The value of the variable total_cost would be determined by retrieving the values of cost and sales tax and inputting them to the ALU. After the values of the variables are added in the ALU, the output would be the value of the variable total_cost.

    And, of course, every letter of every variable would be stored in a byte [likely in ASCII form] as a true binary number. The values of the variables would be stored as signed number in 2's complement form.

    We want to look now at how signed integers such as +100 and +7, stored using 2's complement notation, are added and subtracted.

    Example 1.6.1If R = +9 and S = +5, find R + S in byte-form using 2's complement notation.Solution:Each of the integers is written in 2's complement notation [remember that these representations are the same as sign-magnitude notation.] The two integers are then added using regular binary addition.

    Decimal Addition 2's Complement Addition +9 0000 1001 +5 +0000 0101 +14 0000 1110 Overflow in Binary AdditionThe largest positive integer that can be stored in a byte in 2's complement form is +127, that is 0111 1111. Therefore, any time two positive 2's complement integers are added and the sum of the integers is greater than +127 an overflow will occur.This situation is illustrated in Example 1.6.2 when +100 and +30 are added. Example 1.6.2If R = +100 and S = +30, find R + S Solution:

    Decimal Addition 2's Complement Addition +100 0110 0100 + 30 +0001 1110

  • +130 1000 0010 The sum of the two integers here is indicated to be 1000 0010. Clearly, this sum cannot be a correct representation of the actual sum of +130 because the MSB is 1 which indicates that this binary expression represents a negative number in 2's complement notation. [What negative integer is represented by 1000 0010? How is this related to the actual sum of +100 and +30?] If we designed a circuit to add two positive numbers, some part of the circuit would have to determine when an overflow occurs. The rule is: 2's complement overflow occurs when the carry into the MSB is not equal to the carry out from the MSB. An overflow detector circuit makes this determination. The schematic below illustrates this concept.

    The concept of overflow is examined by looking again at Example 1.6.1 and Example 1.6.2.Example 1.6.1Add +9 and +5 using 2's complement notation.

    The following graphic illustrates what happens in bits 5, 6 and 7 as they are added. In particular, we are interested in the values of the carry in to byte 7 and the carry out from byte 7. If they are equal, no overflow occurs.

    Decimal Addition 2's Complement Addition +9 0000 1001 +5 +0000 0101 +14 0000 1110

  • Both the carry in and carry out values for bit 7, the MSB, have value 0. No overflow occurs.Example 1.6.2Add +100 and +30. Show that an overflow occurs by checking the carry in to and the carry out from the MSB of the sum.

    Decimal Addition 2's Complement Addition +100 0110 0100 + 30 +0001 1110 +130 1000 0010

  • The carry in to the MSB of 1 is not equal to the carry out of 0 from the MSB. An overflow occurs.Subtraction with One's ComplementLet's consider how we would solve our problem of subtracting 110 from 710 using 1's complement.

    1. First, we need to convert 00012 to its negative equivalent in 1's complement.

    0111 (7) - 0001 - (1)

    2. To do this we change all the 1's to 0's and 0's to 1's. Notice that the most-significant digit is now 1 since the number is negative.

    0001 -> 1110

    3. Next, we add the negative value we computed to 01112. This gives us a result of 101012.

    0111 (7) + 1110 +(-1) 10101 (?)

    4. Notice that our addition caused an overflow bit. Whenever we have an overflow bit in 1's complement, we add this bit to our sum to get the correct answer. If there is no overflow bit, then we leave the sum as it is.

    0101 + 1 0110 (6)

    5. This gives us a final answer of 01102 (or 610). 0111 (7) - 0001 - (1) 0110 (6)

    Now let's look at an example where our problem does not generate an overflow bit. We will subtract 710 from 110 using 1's complement.

    1. First, we state our problem in binary. 0001 (1) - 0111 - (7)

  • 2. Next, we convert 01112 to its negative equivalent and add this to 00012.

    0001 (1) + 1000 +(-7) 1001 (?)

    3. This time our results does not cause an overflow, so we do not need to adjust the sum. Notice that our final answer is a negative number since it begins with a 1. Remember that our answer is in 1's complement notation so the correct decimal value for our answer is -610 and not 910.

    0001 (1) + 1000 +(-7) 1001 (-6)

    REPRESENTATION OF FLOATING POINT NUMBERS-----------------------------------------------------------

    Computers represent real values in a form similar to that of scientific notation. There are standards which define what the representation means so that across computers there will be consistency.

    Note that this is not the only way to represent floating point numbers, it is just the IEEE standard way of doing it.

    Here's what we do:

    the representation

    ------------------- | S | E | F | -------------------

    S is one bit representing the sign of the number E is an 8 bit biased integer representing the exponent F is an unsigned integer

    The value represented is: (-1)S x F x 2E

    Where e = E - bias f = F/2n + 1

    For single precision numbers (the emphasis in this class) n = 23 Bias = 127

    Now, what does all this mean? (Everything here is for IEEE single precision floating point representation.) --> S, E, F all represent fields within a representation. Each is just a bunch of bits.

    --> S is just a sign bit. 0 for positive, 1 for negative.

    --> E is an exponent field. The E field is a biased-127 representation. So, the true exponent represented is (E - bias). The radix for the number is ALWAYS 2.

  • Note: Computers that did not use this representation, like those built before the standard, did not always use a radix of 2. Example: some IBM machines had radix of 16.

    --> F is the mantissa. It is in a somewhat modified form. There are 23 bits available for the mantissa. It turns out that if fl. pt. numbers are always stored in a normalized form, then the leading bit (the one on the left, or MSB) is always a 1. So, why store it at all? It gets put back into the number (giving 24 bits of precision for the mantissa) for any calculation, but we only have to store 23 bits.

    This MSB is called the HIDDEN BIT.

    An example: put the decimal number 64.2 into the IEEE single precision representation.

    First step:Get a binary representation for 64.2To do this, get binary reps. for the stuff to the left and right of the decimal point separately.

    64 is 1000000

    .2 can be gotten using the algorithm:

    .2 x 2 = 0.4 0 (msb) .4 x 2 = 0.8 0 .8 x 2 = 1.6 1 .6 x 2 = 1.2 1

    .2 x 2 = 0.4 0 now this whole pattern (0011) repeats. .4 x 2 = 0.8 0 .8 x 2 = 1.6 1 .6 x 2 = 1.2 1

    So a binary representation for .2 is .001100110011. . .

    Putting the halves back together again: 64.2 is 1000000.0011001100110011. . .

    Second step:

    Normalize the binary representation. (make it look like scientific notation) 6

    1.000000 00110011. . . x 2

    Third step:Represent exponent in the standard form(biased)

    6 is the true exponent. For the standard form, it needs to be in biased-127 form.

    6 + 127 ----- 133 (value of biased exponent)

    133 in 8 bit, unsigned representation is 1000 0101

  • This is bit pattern used for E in the standard form.

    Fourth step:

    The mantissa stored (F) is the stuff to the right of the radix point in the normal form. We need 23 bits of it.

    000000 00110011001100110

    Put it all together (and include the correct sign bit):

    S E F 0 10000101 00000000110011001100110

    The values are often given in hex, so here it is

    0100 0010 1000 0000 0110 0110 0110 0110 0x 4 2 8 0 6 6 6 6

    Or 42806666h

    Some extra details:

    --> Since floating point numbers are always stored in normal form, how do we represent 0?

    (What does the fl. pt. number 0x3f80 0000 represent?) (What does the fl. pt. number 0x0080 0000 represent?)

    We take the bit patterns 0x0000 0000 and 0x8000 0000 to represent the value 0.

    (What fl. pt. numbers cannot be represented because of this?)

    --> Other special values:

    +infinity 0 11111111 00000... (0x7f80 0000) -infinity 1 11111111 00000... (0xff80 0000)

    NaN (Not a Number) ? 11111111 ?????...

    (S is either 0 or 1, E=0xff, and F is anything but all zeros)

    ExampleNotation ValueOrdinary Decimal 178.125Scientific Decimal 1.78125 E 102

    Scientific Binary 1.0110010001 E 2111

    Scientific Binary(Biased Exponent)

    1.0110010001 E 210000110

    Single-Real Format Sign Biased Exponent Normalized Significand0 10000110 01100100010000000000000

    (1. implied => J-Bit)

  • When performing normalized floating-point computations, an FPU normally operates on normalized numbers and produces normalized numbers as results. Denormalized numbers represent an underflow condition.

    A denormalized number is computed through a technique called gradual underflow. Table 2 gives an example of gradual underflow in the denormalization process. Here the single-real format is being used, so the minimum exponent (unbiased) is -12610. The true result in this example requires an exponent of -12910 in order to have a normalized number. Since -12910 is beyond the allowable exponent range, the result is denormalized by inserting leading zeros until the minimum exponent of -12610 is reached.

    Operation Sign Exponent* SignificandTrue Result 0 -129 1.01011100000...00Denormalize 0 -128 0.10101110000...00Denormalize 0 -127 0.01010111000...00Denormalize 0 -126 0.00101011100...00Denormal Result 0 -126 0.00101011100...00

    NOTE: * Expressed as an unbiased, decimal number.

    Table 2: Denormalization Process

    In the extreme case, all the significant bits are shifted out to the right by leading zeros, creating a zero result.

    The FPU deals with denormal values in the following ways:

    It avoids creating denormals by normalizing numbers whenever possible.

    It provides the floating-point underflow exception to permit programmers to detect cases when denormals are created.

    It provides the floating-point denormal-operand exception to permit procedures or programs to detect when denormals are being used as source operands for computations.

    BINARYCODEDDECIMAL

    In todays technology, you hear a great deal about microprocessors. A microprocessor is an integrated circuit designed for two purposes: data processing and control. Computers and microprocessors both operate on a series of electrical pulses called words.

    A word can be represented by a binary number such as 101100112.

    Binary-coded decimal, or BCD, is a method of using binary digits to represent the decimal digits 0 through 9.A decimal digit is represented by four binary digits, as shown below:

    http://www.randelshofer.ch/fhw/gri/float.html#table2note#table2notehttp://www.randelshofer.ch/fhw/gri/float.html#table2#table2

  • Example

    Represent 4910 in BCD

    4 -> 01009 -> 1001

    Therefore, 4910 in BCD is 01001001BCD

    REFERENCES

    http://gs.fanshawec.ca/tlc/math270/http://courses.cs.vt.edu/~csonline/NumberSystems/Lessons/BinaryNumbers/index.htmlhttp://www.math.grin.edu/~stone/courses/fundamentals/IEEE-reals.htmlhttp://www.randelshofer.ch/fhw/gri/float.htmlhttp://www.randelshofer.ch/fhw/gri/float.html#chapterfloatapplethttp://www.randelshofer.ch/fhw/gri/doubleapplet.html

    http://www.randelshofer.ch/fhw/gri/doubleapplet.htmlhttp://www.randelshofer.ch/fhw/gri/float.html#chapterfloatapplethttp://www.randelshofer.ch/fhw/gri/float.htmlhttp://www.math.grin.edu/~stone/courses/fundamentals/IEEE-reals.htmlhttp://courses.cs.vt.edu/~csonline/NumberSystems/Lessons/BinaryNumbers/index.htmlhttp://gs.fanshawec.ca/tlc/math270/

    Binary Representation and Computer ArithmeticThe decimal system of counting and keeping track of items was first created by Hindu mathematicians in India in A.D. 400. Since it involved the use of fingers and thumbs, it was natural that this system would have 10 digits. The system found its way to all the Arab countries by A.D. 800, where it was named the Arabic number system, and from there it was eventually adopted by nearly all the European countries by A.D. 1200, where it was called the decimal number system.The key feature that distinguishes one number system from another is the number system'sbase or radix. This base indicates the number of digits that will be used. The decimalnumbersystem, for example, is a base 10 number system which means that it uses 10 digits (0 to 9) to communicate information about an amount. A subscript is something included after a number when different number systems are being used to indicate the base of the number. For example 5327 would represent a number in base 7 (using the digits 0 to 6) number system.110010and 11002are two numbers which contain the same digits but which are written using different bases. The first number we recognize as one thousand one hundred in the decimal (base 10) number system. The second number is a number in the base 2 number system called the binary number system.The Binary System