
. View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by University of Tasmania Open Access Repository Composite Arithmetic: Proposal for Feature a New Standard A general-purpose arithmetic standard could give general computation the kind of reliability and stability that the floating-point standard brought to scientific computing. The author describes composite arithmetic as a possible starting point. W. Neville ver since their early days, digital computers and posite arithmetic combines aspects of traditional Holmes their arithmetics have made different kinds of integer and floating-point arithmetics with less University of E complex computation possible. Frustrated, familiar aspects of rational and logarithmic arith- Tasmania however, by the limitations of integer arithmetic metics to complement the binary floating-point stan- (originally intended for counting loops and calcu- dard and satisfy more diverse computational needs. lating addresses), scientists and engineers developed I describe a formatting scheme for storage and dis- a floating-point number representation. play of exact and inexact numbers and an extended Floating-point arithmetic, or more properly, arith- arithmetic with a number format as its basis. I also metic using scaled numbers, was variously imple- introduce possibilities for implementing the arith- mented, first in software and later in hardware. metic and discuss the interface between the repre- Scientific computing was greatly enhanced by the sentations and the arithmetic. worldwide adoption in 1985 of the ANSI/IEEE stan- dard for binary floating-point arithmetic.1 NUMBER REPRESENTATION Significant growth in general (or popular) com- No matter how varied, computer arithmetics, and puting has led to a widespread use of spreadsheets, the digital forms of the numbers they use, follow a for which floating-point arithmetic is too special- traditional pattern. Fixed-point arithmetic, more cor- ized. Programs such as computer graphics, on the rectly called integer arithmetic outside the comput- other hand, push floating-point arithmetic too far.2 ing industry, is meant to represent and compute with And programmers have long been bedeviled by the integers exactly. In integer arithmetic, calculation with need to choose, often in ignorance, between fixed- fractions is not done directly and must be carried out and floating-point representations for values.3 via subterfuges, such as scaling, which may deliver Although floating-point arithmetic, commonly inexact results. Instead, fractions can be handled by used in pocket calculators and electronic diaries, an arithmetic called floating slash, which has been does not generally yield exact results, ordinary PC proposed5 but not widely adopted. A similar scheme users naturally expect computer calculations to be is built into the composite arithmetic I propose. exact, and some, like accountants, insist on at least Fixed-point arithmetic can handle a relatively lim- the appearance of it. However, one very popular cal- ited range of numbers. More than one length of rep- culator gives the answer –0.000000001 to the cal- resentation is often provided so that the programmer culation ((1 ÷ 3) ✕ 3) – 1!4 Scientists and engineers, can choose a length to cope with the expected range on the other hand, know that their measurements of numbers. But very soon the numbers become too are approximate in the first place, so expect any large to store, a condition called arithmetic over- results the computer gives them, based on those flow, which a program must deal with specially to measurements, to be approximate. prevent wrong results. These circumstances, coupled with developments Floating-point arithmetic was designed to cir- in circuit technology and computation, have cumvent this overflow problem but at the cost of encouraged and made possible a more general arith- exactness. Floating-point arithmetic can cope with metic that saves the programmer from having to a large range of numbers, but it does so only by choose between number representations and gives approximating. More than one length of represen- the user more informative results. In this article tation lets the programmer choose a length that pro- I propose what I call composite arithmetic. Com- duces suitable precision, yet overflow can still occur, 0018-9162/97/$10.00 © 1997 IEEE March 1997 65 . Figure 1. Proposed exact storage forms include (a) primary Tag Value exact form (integer), 00 2s complement integer and (b) secondary n–1 n–3 0 exact form (rational). choice in file and array design that would also provide In the bit numbering as (a) adequate precision for most commercial calculations shown, n stands for the on exact numbers and for most scientific computa- number of bits in the Tag Value tions on inexact numbers. For financial and number form and can be 32, 01± slash denominator \ numerator theory calculations where very long exact results can 64, 128, or 256, while n–1 n–4 n–m–9 0 occur, and for those occasional technical computations m numbers the differ- where very precise results can be required beyond the ent forms in increasing (b) equivalent of 20 decimal digits, 128- and 256-bit stor- size as 0, 1, 2, or 3. age sizes should be provided. Such extra precision is warranted by the proliferation of multiple-precision subroutine libraries. Table 1. Integer storage form sizes.* EXACT FORMS Number Magnitude To free the programmer from having to choose Bits Bytes Bits Digits Length between fixed- and floating-point representation, com- 32 4 29 8.7 Short posite arithmetic merges both exact and inexact rep- 64 8 61 18.4 Normal resentations through a tag bit that signifies whether 128 16 125 37.6 Long the number is stored exactly or not. If the tag bit is 0, 256 32 253 76.2 Extended the number is exact; otherwise it is inexact. Generally, only computation performed entirely with exact num- *Three bits are needed for the tag and the arithmetic sign. bers will produce an exact result. The participation of only a single inexact number will normally produce an inexact result. as can underflow when numbers are too small to rep- In composite arithmetic, a single tag bit isn’t enough: resent. An ideal general-purpose arithmetic would In exact computations both integers and fractional deal exactly with commonly encountered fractions numbers must be available. A second tag bit is there- like 1/3 and $19.99. It would neither overflow nor fore needed to signify whether a primary or a sec- underflow. ondary form is being used. For exact values, primary To attain this ideal arithmetic, we must first pre- is integer form, secondary is rational. scribe a storage form for numbers that combines the advantages of fixed- and floating-point forms and also Integer storage forms better represents fractions and extremely large and For integer storage forms, all but the tag bits can be small numbers. The programmer should not have to used for storing the value, as shown in Figure 1a. One choose between fixed- and floating-point forms—the of the value bits is needed to store the arithmetic sign arithmetic should dynamically determine which is of the number, but the rest of the bits can store the needed. Moreover, users should not have to key in magnitude, as shown in Table 1. numbers in any specific format—the arithmetic In the integer storage form, negative numbers should cope with whatever numbers it gets. should be stored as the 2s complement of their mag- nitude (one plus the bitwise complement of the mag- PROPOSED STORAGE FORMS nitude) so that a negative zero cannot be stored. Zero Composite arithmetic will provide a single binary is always exact. form, for storing numbers in programs and files, that combines several different formats by a method tra- Rational storage forms ditionally known as tagging.6 Arithmetic with rational numbers is as exact as inte- Formatting numbers compositely in any binary ger arithmetic. At least it can be, if appropriate repre- storage has two main aspects. How many bits to use sentation and arithmetic are provided. In exact bears mainly on the precision with which a number arithmetic, values may change from integer to rational can be stored. How the bits are used bears mainly and back again, depending on the computation. on the kind and the value of the number being A rational number typically springs from division stored. of integers and to be exact must have both its denom- The number of bits for a storage form is usually inator and its numerator stored. Rational numbers specified in multiples of 16, as in the IEEE standard are stored in the secondary exact form, for which the for binary floating-point arithmetic that provides 32- tag bits are 0 and 1. This form can store both very and 64-bit formats. Altogether, I recommend four large numbers, in which the numerator is much larger lengths: short (32 bits), normal (64 bits), long (128 than the denominator, and very small numbers, in bits), and extended (256 bits). For composite arith- which the numerator is much smaller than the denom- metic, 32- and 64-bit storage sizes would allow a inator. 66 Computer . Table 2. Approximate ranges of numbers in rational form. Number Value Range Bits Bytes Bits Digits Small Large Length 32 4 24 7.2 6×10–8 4×106 Short 64 8 55 16.6 3×10–17 9×1015 Normal 128 16 118 35.5 3×10–36 8×1034 Long 256 32 245 73.8 2×10–74 1×1073 Extended For efficiency, a rational number’s storage form must provide for sharing the value bits between Table 3. Representing exceptional values. 5 numerator and denominator, as shown in Figure 1b. Value Numerator Denominator Sign Tag So that the numerator can be normalized, this sharing Zero 0 None No 00 must be resolvable to the bit.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages9 Page
-
File Size-