skip to main content
10.1145/93542.93557acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
Article
Free access

How to read floating point numbers accurately

Published: 01 June 1990 Publication History

Abstract

Consider the problem of converting decimal scientific notation for a number into the best binary floating point approximation to that number, for some fixed precision. This problem cannot be solved using arithmetic of any fixed precision. Hence the IEEE Standard for Binary Floating-Point Arithmetic does not require the result of such a conversion to be the best approximation.
This paper presents an efficient algorithm that always finds the best approximation. The algorithm uses a few extra bits of precision to compute an IEEE-conforming approximation while testing an intermediate result to determine whether the approximation could be other than the best. If the approximation might not be the best, then the best approximation is determined by a few simple operations on multiple-precision integers, where the precision is determined by the input. When using 64 bits of precision to compute IEEE double precision results, the algorithm avoids higher-precision arithmetic over 99% of the time.
The input problem considered by this paper is the inverse of an output problem considered by Steele and White: Given a binary floating point number, print a correctly rounded decimal representation of it using the smallest number of digits that will allow the number to be read without loss of accuracy. The Steele and White algorithm assumes that the input problem is solved; an imperfect solution to the input problem, as allowed by the IEEE standard and ubiquitous in current practice, defeats the purpose of their algorithm.

References

[1]
Clinger, William, and Jonathan Rees {editors}. Revisedn report on the algorithmic language Scheme. Technical Report CIS-TR-90-02, Department of Computer and Information Science, University of Oregon, 1990.
[2]
Coonen, Jerome T. An implementation guide to a proposed standard for floating-point arithmetic. Computer 13, 1, January 1980, pages 68-79.
[3]
Goldberg, I. B. 27 bits is not enough for 8-digit accuracy. CACM 10, 2, February 1967, pages 105- 106.
[4]
Hardy, G. H., and E. M. Wright. An Introduction to the Theory of Numbers, Fourth Edition. Oxford University Press, 1960.
[5]
- IEEE Standard 754-1985. IEEE Standard for Binary Floating-Point Arithmetic. IEEE, New York, 1985.
[6]
Knuth, Donald E. The Art of Computer Programming, Second Edition, Volume 2, Seminumerical Algorithms. Addison-Wesley, 1981.
[7]
Matula, David W. In-and-out conversions. CACM 11, 1, January 1968, pages 47-50.
[8]
Matula, David W. A formalization of floatingpoint numeric base conversion. IEEE Transactions on Computers, C-19, 8, August 1970, pages 681-692.
[9]
Rees, Jonathan, and William Clinger {editors}. Revised3 report on the algorithmic language Scheme. A CM SIGPLAN Notices 21, 12, December 1986, pages 37-79.
[10]
Steele Jr, Guy Lewis, and Ion L White. How to print floating point numbers accurately. Proceedings of this conference.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLDI '90: Proceedings of the ACM SIGPLAN 1990 conference on Programming language design and implementation
June 1990
351 pages
ISBN:0897913647
DOI:10.1145/93542
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 June 1990

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Article

Acceptance Rates

Overall Acceptance Rate 406 of 2,067 submissions, 20%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)1,280
  • Downloads (Last 6 weeks)160
Reflects downloads up to 04 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2017)Lexical AnalysisA Practical Approach to Compiler Construction10.1007/978-3-319-52789-5_3(37-73)Online publication date: 23-Mar-2017
  • (2015)Verified Compilation of Floating-Point ComputationsJournal of Automated Reasoning10.1007/s10817-014-9317-x54:2(135-163)Online publication date: 1-Feb-2015
  • (2013)A Formally-Verified C Compiler Supporting Floating-Point ArithmeticProceedings of the 2013 IEEE 21st Symposium on Computer Arithmetic10.1109/ARITH.2013.30(107-115)Online publication date: 7-Apr-2013
  • (2009)Revised6 report on the algorithmic language schemeJournal of Functional Programming10.1017/S095679680999007419:S1(1-301)Online publication date: 1-Aug-2009
  • (2008)The pitfalls of verifying floating-point computationsACM Transactions on Programming Languages and Systems10.1145/1353445.135344630:3(1-41)Online publication date: 21-May-2008
  • (2007)MPFRACM Transactions on Mathematical Software10.1145/1236463.123646833:2(13-es)Online publication date: 1-Jun-2007
  • (2006)Fast Decimal Floating-Point DivisionIEEE Transactions on Very Large Scale Integration (VLSI) Systems10.1109/TVLSI.2006.88404714:9(951-961)Online publication date: Sep-2006
  • (2005)Formal Verification of the VAMP Floating Point UnitFormal Methods in System Design10.1007/s10703-005-1613-y26:3(227-266)Online publication date: 1-May-2005
  • (2004)How to print floating-point numbers accuratelyACM SIGPLAN Notices10.1145/989393.98943139:4(372-389)Online publication date: 1-Apr-2004
  • (2004)Systematic IEEE rounding method for high-speed floating-point multipliersIEEE Transactions on Very Large Scale Integration (VLSI) Systems10.1109/TVLSI.2004.82586012:5(511-521)Online publication date: 1-May-2004
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media