Variable precision arithmetic: a Fortran 95 module

  • Authors:
  • J. L. Schonfelder

  • Affiliations:
  • The University of Liverpool, UK

  • Venue:
  • ACM SIGPLAN Fortran Forum
  • Year:
  • 2001

Quantified Score

Hi-index 0.00

Visualization

Abstract

This paper describes the design and development of a software package supporting variable precision arithmetic as a semantic extension to the core FORTRAN language. The working precision of the arithmetic supported by this package can be dynamically and arbitrarily variable. The facility exploits the data-abstraction capabilities of Fortran 95 and allows the operations to be used elementally with array operands as well as with scalars.The number system is defined in such a way as to be closed under all of the basic operations of normal arithmetic; no program-terminating numerical exceptions can occur. Precision loss situations like underflow and overflow are handled by defining special value representations that preserve as much of the numeric information as is practical and the operation semantics are defined so that these exceptional values propagate as appropriate to reflect this loss of information.The number system uses an essentially conventional variable precision floating-point representation. Where operations can be performed exactly within the currently-set working precision limit, the excess trailing zero digits are not stored, nor do they take part in future operations. This is both economical in storage and improves efficiency. By judiciously managing the working precision, arithmetic operations that are potentially exact can be performed exactly.