From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!helios.ee.lbl.gov!pasteur!tully.Berkeley.EDU!hilfingr From: hilfingr@tully.Berkeley.EDU (Paul Hilfinger) Newsgroups: comp.lang.ada Subject: Fixed-point arithmetic with arbitrary 'SMALL. Message-ID: <25953@pasteur.Berkeley.EDU> Date: 5 Jul 90 02:27:55 GMT Sender: news@pasteur.Berkeley.EDU Reply-To: hilfingr@tully.Berkeley.EDU (Paul Hilfinger) Organization: University of California at Berkeley, Computer Science Division X-Local-Date: 4 Jul 90 19:27:55 PDT List-Id: A Berkeley Tech Report will soon appear on the subject of supporting fixed-point arithmetic with arbitrary scales ('SMALL values)---specifically, values that are not simple powers of 2. It's a bit dense, but may be of interest to implementors and the generally curious. -------------------------------------------------------------------------- Paul N. Hilfinger, "Implementing Ada Fixed-point Types having Arbitrary Scales." Berkeley Report No. UCB/CSD 90/582, June, 1990. 30 pages, $5.00. Abstract (LaTeX source form): Ada implementations have the option of supporting fixed-point arithmetic with arbitrary scale---that is, in which the safe numbers are of the form $m \sigma$ for a fixed, arbitrary rational $\sigma>0$, with $m$ in some contiguous range of integers. The major difficulty with providing such support is the implementation of the mixed-type operations, multiplication and division. If $x$ and $y$ are the integer values representing the operands, these operations reduce to finding integer approximations of $\alpha xy$ or $\beta x/y$ with an absolute error less than~1 for a fixed-point result type, an absolute error less than or equal to~1/2 for an integer result type, or a relative error of less than one safe interval for a floating-point result type. The static constants $\alpha$ and $\beta$ may be arbitrary positive rational numbers, depending on the scales of the two operand types and on the result type. I present reasonably fast ways to compute appropriate fixed-point results for all values of $\alpha$ or $\beta$. For integer result types, I give algorithms for $\alpha$ and $\beta$ that have the form $2^ma/b$, where $a$ and $b$ are positive, single-precision integer constants. Finally, I give algorithms to produce floating-point results for a variety of architectures, including the~VAX, the IBM~370, and those conforming to IEEE Standard~754. --------------------------------------------------------------------------- The address for ordering (for those of you that don't receive them free) is Publications Office 571 Evans Hall University of California at Berkeley Berkeley, CA 94720. Paul N. Hilfinger Electrical Engineering and Computer Sciences Dept. University of California at Berkeley