Printing floating-point numbers quickly and accurately

  • Authors:
  • Robert G. Burger;R. Kent Dybvig

  • Affiliations:
  • Indiana University Computer Science Department, Lindley Hall 215, Bloomington, Indiana;Indiana University Computer Science Department, Lindley Hall 215, Bloomington, Indiana

  • Venue:
  • PLDI '96 Proceedings of the ACM SIGPLAN 1996 conference on Programming language design and implementation
  • Year:
  • 1996

Quantified Score

Hi-index 0.00

Visualization

Abstract

This paper presents a fast and accurate algorithm for printing floating-point numbers in both free- and fixed-format modes. In free-format mode, the algorithm generates the shortest, correctly rounded output string that converts to the same number when read back in, accommodating whatever rounding mode the reader uses. In fixed-format mode, the algorithm generates a correctly rounded output string using special # marks to denote insignificant trailing digits. For both modes, the algorithm employs a fast estimator to scale floating-point numbers efficiently.