ex and
play

EX and Professor William Kahan (Berkeley) Extending T EX and - PowerPoint PPT Presentation

Dedication MET Professor Donald Knuth (Stanford) MET AF ONT with EX and Professor William Kahan (Berkeley) Extending T EX and Floating-Point Arithmetic AF Nelson H. F. Beebe ONT Department of Mathematics T University of Utah Salt Lake


  1. Dedication MET Professor Donald Knuth (Stanford) MET AF ONT with EX and Professor William Kahan (Berkeley) Extending T EX and Floating-Point Arithmetic AF Nelson H. F. Beebe ONT Department of Mathematics T University of Utah Salt Lake City, UT 84112-0090 MET AF ONT MET AF ONT USA MET AF ONT restricts input numbers to 12 integer bits: T EX Users Group Conference 2007 talk... – p. 1/30 T EX Users Group Conference 2007 talk... – p. 2/30 Arithmetic in T EX and Arithmetic in MET MET Binary integer arithmetic with ≥ 32 bits (T EX \count registers) % mf expr EX and EX and gimme an expr: 4095 >> 4095 Fixed-point arithmetic with sign bit, overflow bit, ≥ 14 gimme an expr: 4096 integer bits, and 16 fractional bits (T EX \dimen , ! Enormous number has been reduced. \muskip , and \skip registers) >> 4095.99998 MET AF ONT to work AF AF Overflow detected on division and multiplication but not gimme an expr: infinity >> 4095.99998 on addition (flaw (NHFB), feature (DEK)) gimme an expr: epsilon >> 0.00002 gimme an expr: 1/epsilon Gyrations sometimes needed in ! Arithmetic overflow. with fixed-point numbers ONT ONT >> 32767.99998 gimme an expr: 1/3 >> 0.33333 T Uh, oh. A little while ago one of the quantities T that I was computing got too large, so I’m afraid gimme an expr: 3*(1/3) >> 0.99998 gimme an expr: 1.2 - 2.3 >> -1.1 your answers will be somewhat askew. You’ll probably have to adopt different tactics next gimme an expr: 1.2 - 2.4 >> -1.2 gimme an expr: 1.3 - 2.4 >> -1.09999 time. But I shall try to carry on anyway. T EX Users Group Conference 2007 talk... – p. 3/30 T EX Users Group Conference 2007 talk... – p. 4/30

  2. Historical remarks [cont] Historical remarks MET MET EX and EX and It is difficult today to appreciate that probably the biggest problem facing Floating Point Arithmetic . . . The subject programmers in the early 1950s was scaling numbers so as to achieve is not at all as trivial as most people think, acceptable precision from a fixed-point machine. and it involves a surprising amount of AF AF interesting information. Martin Campbell-Kelly Programming the Mark I: Donald E. Knuth The Art of Computer Programming: Early Programming Activity ONT ONT at the University of Manchester Seminumerical Algorithms , (1998) T Annals of the History of Computing T 2 (2) 130–168 (1980) T EX Users Group Conference 2007 talk... – p. 5/30 T EX Users Group Conference 2007 talk... – p. 6/30 Why no floating-point arithmetic? Historical remarks [cont] MET MET System dependence in precision , range , rounding , Computer hardware designers can make their underflow , overflow machines much more pleasant to use, EX and EX and for example by providing Base varies: 2 , 3 (Setun), 4 (Illiac II), 8 (Burroughs), floating-point arithmetic 10 , 16 (IBM S/360), 256 (Illiac III), 10000 (Maple) which satisfies simple mathematical laws. Bizarre behavior when T EX was developed: The facilities presently available on most AF AF x × y � = y × x (early Crays) machines make the job of rigorous error analysis hopelessly difficult , but properly x � = 1 . 0 × x (Pr1me) designed operations would encourage x + x � = 2 × x (Pr1me) numerical analysts to provide better ONT ONT x � = y but 1 . 0 / ( x − y ) gets zero-divide error subroutines which have certified accuracy. T T wrap between underflow and overflow (PDP-10) Donald E. Knuth job termination on overflow or zero-divide (most) Computer Programming as an Art ACM Turing Award Lecture (1973) No standardization: almost every vendor had unique floating-point system T EX Users Group Conference 2007 talk... – p. 7/30 T EX Users Group Conference 2007 talk... – p. 8/30

  3. Why no floating-point . . . [cont]? Why no floating-point . . . [cont]? MET MET Language dependence: Input/output problem requires base conversion, and is hard (e.g., conversion from 128-bit binary format can Algol, Pascal, and SAIL ( real ) EX and EX and require more than 11 500 decimal digits) Fortran ( REAL , DOUBLE PRECISION , and sometimes DEK wrote A simple program whose proof isn’t REAL*16 ) (1990) about T EX’s conversions between fixed-point C/C++ ( double , float added in 1989, long double binary and decimal in 1999) AF AF Most languages do not guarantee exact base Java and C# (only float and double , but arithmetic system is badly botched: see Kahan and conversion Darcy’s How Java’s Floating-Point Hurts T EX guarantees identical line-breaking and ONT ONT MET AF ONT has no floating-point at all, and generates Everyone Everywhere ) page-breaking across all platforms (floating-point T T Compiler dependence: multiple precisions mapped to arithmetic used only for interword glue calculations) just one BSD compilers still provide no 80-bit format after 27 identical fonts on all systems years in hardware T EX Users Group Conference 2007 talk... – p. 9/30 T EX Users Group Conference 2007 talk... – p. 10/30 IEEE 754 binary standard (1985) IEEE 754 binary standard [cont] MET MET Preliminary version first implemented in Intel 8087 chip Nonstop computing model: sticky flags record (1980) exceptions EX and EX and Three formats defined: 32-bit, 64-bit, and 80-bit. Four rounding modes: 128-bit format available on some Alpha, IA-64, and to nearest with ties to even (default) SPARC systems. to + ∞ AF AF Nonzero normal numbers are rational : to −∞ x = ( − 1) s f × 2 p , where f ∈ [1 , 2) to zero (historical chopping) Signed zero ±∞ generated from large/small and finite/0 ONT ONT Largest stored exponent represents Infinity when NaN generated from 0/0, ∞ − ∞ , ∞ / ∞ , and any f = 0 , quiet and signaling NaN (Not-a-Number) when T T operation with a NaN operand f � = 0 NaN returned from functions when result is undefined in real arithmetic (e.g., √− 1 ) Smallest stored exponent allows f to have leading zeros with gradual underflow to subnormal values T EX Users Group Conference 2007 talk... – p. 11/30 T EX Users Group Conference 2007 talk... – p. 12/30

  4. IEEE 754R Precision and range Remark on floating-point arithmetic MET MET Contrary to popular misconception, even in some books Binary EX and EX and and compilers, floating-point arithmetic is not fuzzy . 32-bit 24b ( ≈ 7D) 1e-45 1e-38 3e+38 64-bit 53b ( ≈ 15D) 4e-324 2e-308 1e+308 Results are exact if they are representable 80-bit 64b ( ≈ 19D) 3e-4951 3e-4932 1e+4932 Multiplication by power of base is always exact, in 128-bit 113b ( ≈ 34D) 6e-4966 3e-4932 1e+4932 absence of underflow and overflow AF AF 256-bit 234b ( ≈ 70D) 2e-315723 5e-315653 3e+315652 Subtraction of numbers of like signs and exponents is Decimal exact 32-bit 7D 1e-101 1e-95 1e+96 ONT ONT 64-bit 16D 1e-398 1e-383 1e+384 T T 128-bit 34D 1e-6176 1e-6143 1e+6144 256-bit 70D 1e-1572932 1e-1572863 1e+15782864 T EX Users Group Conference 2007 talk... – p. 13/30 T EX Users Group Conference 2007 talk... – p. 14/30 Binary versus decimal Binary versus decimal [cont] MET MET IEEE 854 Standard for Radix-Independent humans less uncomfortable with decimal arithmetic Floating-Point Arithmetic (1987, 1994) EX and EX and sales tax: 5% of 0 . 70 = 0 . 0349999 . . . in all binary older Cobol standards require 18D fixed-point precisions, instead of exact decimal 0 . 035 . Thus, Cobol 2002 requires 32D fixed-point and floating-point significant cumulative rounding errors in businesses with many small transactions (food, telephone, . . . ) Proposals to add decimal arithmetic to C and C++ AF AF (2005, 2006) financial computations need fixed-point decimal arithmetic 25 years of Rexx and NetRexx scripting languages give valuable experience in arbitrary-precision decimal hand calculators use decimal arithmetic ONT ONT arithmetic additional decimal rounding rules (8 instead of 4) T T excellent IBM decNumber library provides open source decimal arithmetic eliminates most base-conversion decimal floating-point arithmetic with a billion ( 10 9 ) problems digits of precision and exponent magnitudes up to 999 999 999 T EX Users Group Conference 2007 talk... – p. 15/30 T EX Users Group Conference 2007 talk... – p. 16/30

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend