SlideShare a Scribd company logo
DECIMAL
 ARITHMETIC
Peeyush Pashine
Contents

• Why increasing emphasis on Decimal
Arithmetic?
• Problems caused by Floating Point?
• Disaster ( Examples)
• How Floating to Decimal?
• Is Hardware supports decimal arithmetic
directly?
Why Decimal Arithmetic?
   Most computers today support binary floating-
    point in hardware.
   But for financial, commercial, and human-
    centric (such as Web) applications – NOT
    suitable.
   In many commercial applications, including
    financial analysis, banking, tax calculation,
    currency conversions, insurance, accounting,
    and e-commerce, the errors introduced by
    converting between decimal and binary
    numbers are unacceptable and may violate
What problems are caused by
using binary floating-point?
   Binary floating-point cannot exactly represent
    decimal fractions.
          DECIMAL      BINARY
        0.9         0.9
        0.09        0.089999996
        0.009       0.0090
        0.0009      9.0E-4
        0.00009     9.0E-5
        0.000009    9.0E-6
        9E-7        9.0000003E-7
        9E-8        9.0E-8
        9E-9        9.0E-9
        9E-10       8.9999996E-10
Example
   For example, using the Java or C double datatype,
    0.1 × 8 (a binary multiple) gives the result
    0.800000000000000044408920985006261616945
    2667236328125
   but 0.1 added to itself 8 times gives the different
    answer
    0.799999999999999933386618522490607574582
    09991455078125.
   The two results would not compare equal, and
    further, if these values are multiplied by ten and
    rounded to the nearest integer below (the „floor‟
    function), the result will be 8 in one case and 7 in
    the other.
   Similarly, the result of 1.30 x 1.05 using binary is
    1.3650000000000002131628207280300557613
    372802734375; this would be rounded up to
    $1.37. However, the result should have been
    1.365 – which would be rounded down to $1.36
    (using “Banker‟s rounding”).
   Taken over a million transactions of this kind, as
    in the „telco‟ benchmark, these systematic errors
    add up to an overcharge of more than $20. For a
    large company, the million calls might be two-
    minutes-worth; over a whole year the error then
   for (double d = 0.1; d <= 0.5; d += 0.1)
    System.out.println(d);

   for (double d = 1.1; d <= 1.5; d += 0.1)
    System.out.println(d);
FAILURES
The Patriot Missile Failure
   On February 25, 1991, during the Gulf War, an American Patriot Missile
    battery in Dharan, Saudi Arabia, failed to track and intercept an incoming
    Iraqi Scud missile.

   A report of the General Accounting office, GAO/IMTEC-92-26,
    entitled Patriot Missile Defense: Software Problem Led to System Failure
    at Dhahran, Saudi Arabia reported on the cause of the failure.

   The cause was an inaccurate calculation of the time since boot due to
    computer arithmetic errors.
   Specifically, the time in tenths of second as
    measured by the system's internal clock was
    multiplied by 1/10 to produce the time in
    seconds.
Explosion of the Ariane 5
   On June 4, 1996 an unmanned Ariane 5 rocket launched by the European
    Space Agency exploded just forty seconds after lift-off (918K QuickTime
    movie).

   The cause of the failure was a software error in the inertial reference
    system.

   Specifically a 64 bit floating point number relating to

    the horizontal velocity of the rocket with respect to the

    platform was converted to a 16 bit signed integer. The

    number was larger than 32,768, the largest integer

    storeable in a 16 bit signed integer, and thus the conversion

    failed.
The applications actually use
decimal data
    Airline systems, Banking, Financial Analysis,
     Insurance, Inventory control, Management
     reporting, Marketing services, Order entry,
     Order processing, Pharmaceutical
     applications, and Retail sales.
How much precision and range is
needed for decimal arithmetic?
    This depends, of course, on the application.
What rounding modes are needed
for decimal arithmetic?
    The three most important are
      Round-half-even

      Round-half-up

      Round-half-up
What disadvantages are there in
using decimal arithmetic?
   Decimal numbers are traditionally held in a
    binary coded decimal form which uses about
    20% more storage than a purely binary
    representation.

   Some properties that hold for binary do not hold
    for any other base. For example, (d ÷ 2) × 2
    gives d in binary (unless there is an underflow),
    but with base 10 it might not if d is full precision
    and d ÷ 2 is Inexact.
The first division illustrates dividing 2.1 into 123.4 . Since we are working
with integers, this is equivalent to dividing 21 into 1234. The result is 58
and contains no decimal point. This will not give us the precision we
demand in the quotient. In the second division, by shifting the dividend to
the left by one digit (bringing in a 0 on the right), we are effectively dividing
21 into 12340, and producing a quotient of 587 which could be edited to
58.7 for printing.
   for (i=0.1; i<0.5; i=i+0.1) printf
    ("%fn",100000000*i);
   will print out:
     100000001.490116

     200000002.980232

     300000011.920929

     400000005.960464
for (num=1.1; num<=1.5; for (num=0.1; num<=0.5;
num=num+0.1)            num=num+0.1)
printf ("%fn",num);    printf ("%fn",num);


prints:                 prints:
   1.100000             0.100000
   1.200000             0.200000
   1.300000             0.300000
   1.400000             0.400000
                        0.500000
Why doesn’t hardware support
decimal arithmetic directly?
   Most computer architectures other than „pure
    RISC‟ machines do, in fact, provide some form
    of decimal arithmetic instructions or support.
   The native (hardware) decimal floating-point
    arithmetic now available in the IBM Power6
    processor and expected in the z6
    microprocessor makes programming far
    simpler and more robust, and with much better
    performance than software
DIFFERENT WAYS
      INVOLVED
Why is decimal arithmetic
unnormalized?
   Unnormalized arithmetic is compatible with
    existing languages and applications.
   The arithmetic of all existing decimal datatypes
    can be derived by constraining the
    unnormalized arithmetic.
   Unnormalized arithmetic often permits
    performance improvements.
   Gradual underflow is „free‟.
Why is decimal arithmetic
unnormalized?
   Zeros are not special cases.
   Conversions to and from existing decimal
    datatypes are faster.
   Unnormalized arithmetic results match human
    expectations.
   Application design is simpler.
How are decimal numbers
    encoded?
   Plimit, the maximum precision of the coefficient. This is the
    maximum length of the coefficient, in digits. Any result from an
    operation which needs more digits than this will be rounded to fit.
    If this rounding caused non-zero digits to be removed, the result
    is Inexact.

   Elimit, the maximum encoded exponent. The encoded exponent is
    a non-negative number, in the range 0 through Elimit, from which
    the exponent parameter is calculated by subtracting a bias. (This
    use of a bias makes it easier to compare exponents in a hardware
    implementation.)
How is the exponent bias
    chosen?
   A balanced range of exponents is defined by the parameters,
    Emax and Emin, which determine the overflow threshold
    (10×10Emax) and the underflow threshold (1×10Emin) respectively.

   In addition to the normal numbers, it must also be possible to
    encode a further range of numbers of lower precision which are
    smaller than the underflow precision. These numbers are
    called subnormal numbers. The smallest subnormal number
    must be 1×10Etiny, where Etiny is given by Emin - (Plimit - 1). In our
    example     format,   the   range    of   subnormal     numbers     is
    1×10Etiny       through        999999×10Etiny         (which        is
How is the exponent bias
chosen?(cont..)
   In a redundant encoding, more than one coefficient
    (with an appropriate exponent) can be used to
    represent a given numerical value (for example, the
    underflow threshold could be represented as either
    1000000×10Etiny or 1×10Emin).
   In a non-redundant encoding, only one coefficient is
    used for a given numerical value. (The coefficient
    chosen usually depends on the scale – when the scale
    is 0 the smallest coefficient is preferred).
Decimal Format Parameters
Conversion
   How many decimal digits are needed to
    represent a binary floating-point number as an
    exact fraction?

   How many decimal digits are needed to
    represent a binary floating-point number
    reversibly?

More Related Content

What's hot

Chapter 03 number system 3o-p
Chapter 03 number system 3o-pChapter 03 number system 3o-p
Chapter 03 number system 3o-pIIUI
 
Chapter 03 number system 2o-p
Chapter 03 number system 2o-pChapter 03 number system 2o-p
Chapter 03 number system 2o-pIIUI
 
Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...
Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...
Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...
Changyu Dong
 
Number systems
Number systemsNumber systems
Number systems
thechamp3
 
Introduction number systems and conversion
 Introduction number systems and conversion Introduction number systems and conversion
Introduction number systems and conversionkanyuma jitjumnong
 
Number system
Number system Number system
Number system
SIVALAKSHMIPANNEERSE
 
NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING
karishma gupta
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of informationRoma Kimberly Erolin
 
6.3 area under norm curve
6.3 area under norm curve6.3 area under norm curve
6.3 area under norm curveleblance
 

What's hot (14)

Chapter 03 number system 3o-p
Chapter 03 number system 3o-pChapter 03 number system 3o-p
Chapter 03 number system 3o-p
 
Perpuluhan (decimals)
Perpuluhan (decimals)Perpuluhan (decimals)
Perpuluhan (decimals)
 
Pp02
Pp02Pp02
Pp02
 
Chapter 03 number system 2o-p
Chapter 03 number system 2o-pChapter 03 number system 2o-p
Chapter 03 number system 2o-p
 
Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...
Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...
Betrayal, Distrust, and Rationality: Smart Counter-Collusion Contracts for Ve...
 
Lp graphical and simplexx892
Lp graphical and simplexx892Lp graphical and simplexx892
Lp graphical and simplexx892
 
Number systems
Number systemsNumber systems
Number systems
 
Introduction number systems and conversion
 Introduction number systems and conversion Introduction number systems and conversion
Introduction number systems and conversion
 
Number system
Number system Number system
Number system
 
NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING NON LINEAR PROGRAMMING
NON LINEAR PROGRAMMING
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of information
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
6.3 area under norm curve
6.3 area under norm curve6.3 area under norm curve
6.3 area under norm curve
 
09 arithmetic
09 arithmetic09 arithmetic
09 arithmetic
 

Viewers also liked

Dependable Systems - Introduction (1/16)
Dependable Systems - Introduction (1/16)Dependable Systems - Introduction (1/16)
Dependable Systems - Introduction (1/16)
Peter Tröger
 
Class10
Class10Class10
Class10
Wasi Ahmad
 
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Silicon Mentor
 
Fixed-point arithmetic
Fixed-point arithmeticFixed-point arithmetic
Fixed-point arithmetic
David Bařina
 
Optimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGAOptimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGA
Dr. Pushpa Kotipalli
 
Approximation and error
Approximation and errorApproximation and error
Approximation and errorrubenarismendi
 
Representation of Real Numbers
Representation of Real NumbersRepresentation of Real Numbers
Representation of Real Numbers
Forrester High School
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
MOHAN MOHAN
 
Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...
IOSR Journals
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
Ritu Ranjan Shrivastwa
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGA
Azhar Syed
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
Balakrishna Chowdary
 
Chapter 5 international compensation
Chapter   5 international compensationChapter   5 international compensation
Chapter 5 international compensation
Preeti Bhaskar
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errorsmaheej
 

Viewers also liked (16)

Dependable Systems - Introduction (1/16)
Dependable Systems - Introduction (1/16)Dependable Systems - Introduction (1/16)
Dependable Systems - Introduction (1/16)
 
Es272 ch2
Es272 ch2Es272 ch2
Es272 ch2
 
Class10
Class10Class10
Class10
 
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
 
Fixed-point arithmetic
Fixed-point arithmeticFixed-point arithmetic
Fixed-point arithmetic
 
Optimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGAOptimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGA
 
Approximation and error
Approximation and errorApproximation and error
Approximation and error
 
Representation of Real Numbers
Representation of Real NumbersRepresentation of Real Numbers
Representation of Real Numbers
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
 
06 floating point
06 floating point06 floating point
06 floating point
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGA
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Chapter 5 international compensation
Chapter   5 international compensationChapter   5 international compensation
Chapter 5 international compensation
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errors
 

Similar to Decimal arithmetic in Processors

fixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.pptfixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.ppt
RavikumarR77
 
Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.
jhugg
 
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Blue Elephant Consulting
 
Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...
Blue Elephant Consulting
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
bmangesh
 
IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...
IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...
IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...
zeeshanshanzy009
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
IJERD Editor
 
Complement.pdf
Complement.pdfComplement.pdf
Complement.pdf
MICHAELJOHNPEDRASA1
 
ALGO.ppt
ALGO.pptALGO.ppt
ALGO.ppt
PidoonEsm
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
Sheba41
 
Faster computation with matlab
Faster computation with matlabFaster computation with matlab
Faster computation with matlab
Muhammad Alli
 
Using BigDecimal and double
Using BigDecimal and doubleUsing BigDecimal and double
Using BigDecimal and double
Peter Lawrey
 
Data representation computer architecture
Data representation  computer architectureData representation  computer architecture
Data representation computer architecture
study cse
 
Problem 7PurposeBreak apart a complicated system.ConstantsC7C13.docx
Problem 7PurposeBreak apart a complicated system.ConstantsC7C13.docxProblem 7PurposeBreak apart a complicated system.ConstantsC7C13.docx
Problem 7PurposeBreak apart a complicated system.ConstantsC7C13.docx
LacieKlineeb
 
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
C++ Homework Help
 
crc_checksum.pdf
crc_checksum.pdfcrc_checksum.pdf
crc_checksum.pdf
ssuser8b4eb21
 
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
Naoki Shibata
 
Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbers
PVS-Studio
 
computer architecture
computer architecture computer architecture
computer architecture
Dr.Umadevi V
 

Similar to Decimal arithmetic in Processors (20)

fixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.pptfixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.ppt
 
Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.
 
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
Intro To C++ - Cass 11 - Converting between types, formatting floating point,...
 
Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...Intro To C++ - Class 11 - Converting between types, formatting floating point...
Intro To C++ - Class 11 - Converting between types, formatting floating point...
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
 
IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...
IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...
IEEE-754 standard format to handle Floating-Point calculations in RISC-V CPUs...
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Complement.pdf
Complement.pdfComplement.pdf
Complement.pdf
 
ALGO.ppt
ALGO.pptALGO.ppt
ALGO.ppt
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
 
Faster computation with matlab
Faster computation with matlabFaster computation with matlab
Faster computation with matlab
 
Using BigDecimal and double
Using BigDecimal and doubleUsing BigDecimal and double
Using BigDecimal and double
 
Data representation computer architecture
Data representation  computer architectureData representation  computer architecture
Data representation computer architecture
 
Problem 7PurposeBreak apart a complicated system.ConstantsC7C13.docx
Problem 7PurposeBreak apart a complicated system.ConstantsC7C13.docxProblem 7PurposeBreak apart a complicated system.ConstantsC7C13.docx
Problem 7PurposeBreak apart a complicated system.ConstantsC7C13.docx
 
C++ Homework Help
C++ Homework HelpC++ Homework Help
C++ Homework Help
 
crc_checksum.pdf
crc_checksum.pdfcrc_checksum.pdf
crc_checksum.pdf
 
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
(Slides) Efficient Evaluation Methods of Elementary Functions Suitable for SI...
 
Final
FinalFinal
Final
 
Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbers
 
computer architecture
computer architecture computer architecture
computer architecture
 

More from Peeyush Pashine

Temperature Controlled Fan Report
Temperature Controlled Fan ReportTemperature Controlled Fan Report
Temperature Controlled Fan ReportPeeyush Pashine
 
Temperature Controlled Fan
Temperature Controlled FanTemperature Controlled Fan
Temperature Controlled FanPeeyush Pashine
 
Parallel Prefix Adders Presentation
Parallel Prefix Adders PresentationParallel Prefix Adders Presentation
Parallel Prefix Adders PresentationPeeyush Pashine
 
Good report on Adders/Prefix adders
Good report on Adders/Prefix addersGood report on Adders/Prefix adders
Good report on Adders/Prefix addersPeeyush Pashine
 
Report adders
Report addersReport adders
Report adders
Peeyush Pashine
 

More from Peeyush Pashine (17)

Temperature Controlled Fan Report
Temperature Controlled Fan ReportTemperature Controlled Fan Report
Temperature Controlled Fan Report
 
Temperature Controlled Fan
Temperature Controlled FanTemperature Controlled Fan
Temperature Controlled Fan
 
Robots
RobotsRobots
Robots
 
Power Ingredients
Power IngredientsPower Ingredients
Power Ingredients
 
Itms
ItmsItms
Itms
 
Ecg
EcgEcg
Ecg
 
Dsp Presentation
Dsp PresentationDsp Presentation
Dsp Presentation
 
Adder Presentation
Adder PresentationAdder Presentation
Adder Presentation
 
My Report on adders
My Report on addersMy Report on adders
My Report on adders
 
Control Unit Working
Control Unit WorkingControl Unit Working
Control Unit Working
 
Parallel Prefix Adders Presentation
Parallel Prefix Adders PresentationParallel Prefix Adders Presentation
Parallel Prefix Adders Presentation
 
Smith Adder
Smith AdderSmith Adder
Smith Adder
 
Smith Adder
Smith AdderSmith Adder
Smith Adder
 
Good report on Adders/Prefix adders
Good report on Adders/Prefix addersGood report on Adders/Prefix adders
Good report on Adders/Prefix adders
 
Kogge Stone Adder
Kogge Stone AdderKogge Stone Adder
Kogge Stone Adder
 
111adder
111adder111adder
111adder
 
Report adders
Report addersReport adders
Report adders
 

Decimal arithmetic in Processors

  • 2. Contents • Why increasing emphasis on Decimal Arithmetic? • Problems caused by Floating Point? • Disaster ( Examples) • How Floating to Decimal? • Is Hardware supports decimal arithmetic directly?
  • 3. Why Decimal Arithmetic?  Most computers today support binary floating- point in hardware.  But for financial, commercial, and human- centric (such as Web) applications – NOT suitable.  In many commercial applications, including financial analysis, banking, tax calculation, currency conversions, insurance, accounting, and e-commerce, the errors introduced by converting between decimal and binary numbers are unacceptable and may violate
  • 4. What problems are caused by using binary floating-point?  Binary floating-point cannot exactly represent decimal fractions. DECIMAL BINARY 0.9 0.9 0.09 0.089999996 0.009 0.0090 0.0009 9.0E-4 0.00009 9.0E-5 0.000009 9.0E-6 9E-7 9.0000003E-7 9E-8 9.0E-8 9E-9 9.0E-9 9E-10 8.9999996E-10
  • 5. Example  For example, using the Java or C double datatype, 0.1 × 8 (a binary multiple) gives the result 0.800000000000000044408920985006261616945 2667236328125  but 0.1 added to itself 8 times gives the different answer 0.799999999999999933386618522490607574582 09991455078125.  The two results would not compare equal, and further, if these values are multiplied by ten and rounded to the nearest integer below (the „floor‟ function), the result will be 8 in one case and 7 in the other.
  • 6. Similarly, the result of 1.30 x 1.05 using binary is 1.3650000000000002131628207280300557613 372802734375; this would be rounded up to $1.37. However, the result should have been 1.365 – which would be rounded down to $1.36 (using “Banker‟s rounding”).  Taken over a million transactions of this kind, as in the „telco‟ benchmark, these systematic errors add up to an overcharge of more than $20. For a large company, the million calls might be two- minutes-worth; over a whole year the error then
  • 7. for (double d = 0.1; d <= 0.5; d += 0.1) System.out.println(d);  for (double d = 1.1; d <= 1.5; d += 0.1) System.out.println(d);
  • 9. The Patriot Missile Failure  On February 25, 1991, during the Gulf War, an American Patriot Missile battery in Dharan, Saudi Arabia, failed to track and intercept an incoming Iraqi Scud missile.  A report of the General Accounting office, GAO/IMTEC-92-26, entitled Patriot Missile Defense: Software Problem Led to System Failure at Dhahran, Saudi Arabia reported on the cause of the failure.  The cause was an inaccurate calculation of the time since boot due to computer arithmetic errors.  Specifically, the time in tenths of second as measured by the system's internal clock was multiplied by 1/10 to produce the time in seconds.
  • 10. Explosion of the Ariane 5  On June 4, 1996 an unmanned Ariane 5 rocket launched by the European Space Agency exploded just forty seconds after lift-off (918K QuickTime movie).  The cause of the failure was a software error in the inertial reference system.  Specifically a 64 bit floating point number relating to the horizontal velocity of the rocket with respect to the platform was converted to a 16 bit signed integer. The number was larger than 32,768, the largest integer storeable in a 16 bit signed integer, and thus the conversion failed.
  • 11. The applications actually use decimal data  Airline systems, Banking, Financial Analysis, Insurance, Inventory control, Management reporting, Marketing services, Order entry, Order processing, Pharmaceutical applications, and Retail sales.
  • 12. How much precision and range is needed for decimal arithmetic?  This depends, of course, on the application.
  • 13. What rounding modes are needed for decimal arithmetic?  The three most important are  Round-half-even  Round-half-up  Round-half-up
  • 14. What disadvantages are there in using decimal arithmetic?  Decimal numbers are traditionally held in a binary coded decimal form which uses about 20% more storage than a purely binary representation.  Some properties that hold for binary do not hold for any other base. For example, (d ÷ 2) × 2 gives d in binary (unless there is an underflow), but with base 10 it might not if d is full precision and d ÷ 2 is Inexact.
  • 15. The first division illustrates dividing 2.1 into 123.4 . Since we are working with integers, this is equivalent to dividing 21 into 1234. The result is 58 and contains no decimal point. This will not give us the precision we demand in the quotient. In the second division, by shifting the dividend to the left by one digit (bringing in a 0 on the right), we are effectively dividing 21 into 12340, and producing a quotient of 587 which could be edited to 58.7 for printing.
  • 16. for (i=0.1; i<0.5; i=i+0.1) printf ("%fn",100000000*i);  will print out:  100000001.490116  200000002.980232  300000011.920929  400000005.960464
  • 17. for (num=1.1; num<=1.5; for (num=0.1; num<=0.5; num=num+0.1) num=num+0.1) printf ("%fn",num); printf ("%fn",num); prints: prints: 1.100000 0.100000 1.200000 0.200000 1.300000 0.300000 1.400000 0.400000 0.500000
  • 18. Why doesn’t hardware support decimal arithmetic directly?  Most computer architectures other than „pure RISC‟ machines do, in fact, provide some form of decimal arithmetic instructions or support.  The native (hardware) decimal floating-point arithmetic now available in the IBM Power6 processor and expected in the z6 microprocessor makes programming far simpler and more robust, and with much better performance than software
  • 19. DIFFERENT WAYS INVOLVED
  • 20.
  • 21.
  • 22. Why is decimal arithmetic unnormalized?  Unnormalized arithmetic is compatible with existing languages and applications.  The arithmetic of all existing decimal datatypes can be derived by constraining the unnormalized arithmetic.  Unnormalized arithmetic often permits performance improvements.  Gradual underflow is „free‟.
  • 23. Why is decimal arithmetic unnormalized?  Zeros are not special cases.  Conversions to and from existing decimal datatypes are faster.  Unnormalized arithmetic results match human expectations.  Application design is simpler.
  • 24. How are decimal numbers encoded?  Plimit, the maximum precision of the coefficient. This is the maximum length of the coefficient, in digits. Any result from an operation which needs more digits than this will be rounded to fit. If this rounding caused non-zero digits to be removed, the result is Inexact.  Elimit, the maximum encoded exponent. The encoded exponent is a non-negative number, in the range 0 through Elimit, from which the exponent parameter is calculated by subtracting a bias. (This use of a bias makes it easier to compare exponents in a hardware implementation.)
  • 25. How is the exponent bias chosen?  A balanced range of exponents is defined by the parameters, Emax and Emin, which determine the overflow threshold (10×10Emax) and the underflow threshold (1×10Emin) respectively.  In addition to the normal numbers, it must also be possible to encode a further range of numbers of lower precision which are smaller than the underflow precision. These numbers are called subnormal numbers. The smallest subnormal number must be 1×10Etiny, where Etiny is given by Emin - (Plimit - 1). In our example format, the range of subnormal numbers is 1×10Etiny through 999999×10Etiny (which is
  • 26. How is the exponent bias chosen?(cont..)  In a redundant encoding, more than one coefficient (with an appropriate exponent) can be used to represent a given numerical value (for example, the underflow threshold could be represented as either 1000000×10Etiny or 1×10Emin).  In a non-redundant encoding, only one coefficient is used for a given numerical value. (The coefficient chosen usually depends on the scale – when the scale is 0 the smallest coefficient is preferred).
  • 28. Conversion  How many decimal digits are needed to represent a binary floating-point number as an exact fraction?  How many decimal digits are needed to represent a binary floating-point number reversibly?