Skip to main content

Languages and Compilers

  • Chapter
  • First Online:
Handbook of Floating-Point Arithmetic

Abstract

The previous chapters have given an overview of interesting properties and algorithms that can be built on an IEEE 754-compliant floating-point arithmetic. In this chapter, we discuss the practical issues encountered when trying to implement such algorithms in actual computers using actual programming languages. In particular, we discuss the relationship between standard compliance, portability, accuracy, and performance. This chapter is useful to programmers wishing to obtain a standard-compliant behavior from their programs, but it is also useful for understanding how performance may be improved by relaxing standard compliance and also what traps one may fall into.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 129.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 169.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 169.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    This requirement was introduced in C89 and kept in the subsequent C99 and C11 standards. The original Kernighan and Ritchie C [333] allowed regrouping, even with explicit parentheses in expressions.

  2. 2.

    The International Standard Organization and the International Electrotechnical Commission are two sister international organizations whose members are, respectively, 163 national standard bodies and 83 national committees.

  3. 3.

    http://tigcc.ticalc.org/doc/float.html#FLT_RADIX.

  4. 4.

    VFP stands for “Vector Floating-Point” but the vector mode was removed shortly after its introduction.

  5. 5.

    See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61399 for instance.

  6. 6.

    The SPARC architecture has instructions for quadruple precision, but in practice, current processors generate traps to compute the results in software.

  7. 7.

    Details on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37845, fixed for GCC 4.9.

  8. 8.

    The C11 standard still does not specify a power function with an integer type as the second argument.

  9. 9.

    Note, however, that this formalization just comes from an interpretation of the ISO C standard, which is written in plain English. Before version 2.5, CompCert behaved differently from other compilers by not rejecting a lexically invalid program.

  10. 10.

    When is_iec559 is true, the C++ standard mandates that infinities and NaNs are available.

  11. 11.

    round_style is a constant member. Therefore, it may well be set to the default round_to_nearest style, even if the architecture allows us to change the rounding direction on the fly.

  12. 12.

    For Python3: https://docs.python.org/3/reference/datamodel.html; For Python2: https://docs.python.org/2/reference/datamodel.html.

  13. 13.

    https://scipy.org/.

  14. 14.

    http://www.ecma-international.org/ecma-262/5.1/.

References

  1. B. Amedro, V. Bodnartchouck, D. Caromel, C. Delbé, F. Huet, and G. L. Taboada. Current state of Java for HP. Preprint, Technical Report 0353, INRIA, 2008. Available at http://hal.inria.fr/inria-00312039/en.

  2. ARM. ARM Developer Suite: Compilers and Libraries Guide. ARM Limited, November 2001. Available at http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0067d/index.html or in PDF at http://infocenter.arm.com/help/topic/com.arm.doc.dui0067d/DUI0067.pdf.

  3. ARM. ARM Developer Suite: Developer Guide. ARM Limited, 1.2 edition, November 2001. Available at http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0056d/index.html or in PDF at http://infocenter.arm.com/help/topic/com.arm.doc.dui0056d/DUI0056.pdf.

  4. ARM. ARM Compiler: armasm User Guide. ARM Limited, 6.7 edition, 2017. Available at http://infocenter.arm.com/help/topic/com.arm.doc.100069_0607_00_en/ or in PDF at http://infocenter.arm.com/help/topic/com.arm.doc.100069_0607_00_en/armasm_user_guide_100069_0607_00_en.pdf.

  5. S. Boldo, J.-H. Jourdan, X. Leroy, and G. Melquiond. Verified compilation of floating-point computations. Journal of Automated Reasoning, 54(2):135–163, 2015.

    Article  MathSciNet  Google Scholar 

  6. F. de Dinechin, E. McIntosh, and F. Schmidt. Massive tracking on heterogeneous platforms. In 9th International Computational Accelerator Physics Conference (ICAP), October 2006.

    Google Scholar 

  7. D. Goldberg. What every computer scientist should know about floating-point arithmetic. ACM Computing Surveys, 23(1):5–48, 1991. An edited reprint is available at https://docs.oracle.com/cd/E19059-01/fortec6u2/806-7996/806-7996.pdf from Sun’s Numerical Computation Guide; it contains an addendum Differences Among IEEE 754 Implementations, also available at http://www.validlab.com/goldberg/addendum.html.

    Article  Google Scholar 

  8. J. Gosling, B. Joy, G. Steele, G. Bracha, and A. Buckley. The Java Language Specification, Java SE 8 edition. Oracle, 2015.

    Google Scholar 

  9. International Organization for Standardization. Programming Languages – C. ISO/IEC Standard 9899:1999, Geneva, Switzerland, December 1999.

    Google Scholar 

  10. Rationale for International Standard—Programming Languages—C, 2003. Revision 5.10. Available at http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf.

  11. International Organization for Standardization. Programming languages – Fortran – Part 1: Base language. International Standard ISO/IEC 1539-1:2004, 2004.

    Google Scholar 

  12. International Organization for Standardization. Programming Languages – C. ISO/IEC Standard 9899:2011, Geneva, Switzerland, November 2011.

    Google Scholar 

  13. International Organization for Standardization. Floating-point extensions for C – Part 1: Binary floating-point arithmetic. ISO/IEC Technical Specification 18661-1:2014, Geneva, Switzerland, July 2014.

    Google Scholar 

  14. International Organization for Standardization. Floating-point extensions for C – Part 2: Decimal floating-point arithmetic. ISO/IEC Technical Specification 18661-2:2015, Geneva, Switzerland, May 2015.

    Google Scholar 

  15. International Organization for Standardization. Floating-point extensions for C – Part 3: Interchange and extended types. ISO/IEC Technical Specification 18661-3:2015, Geneva, Switzerland, October 2015.

    Google Scholar 

  16. International Organization for Standardization. Floating-point extensions for C – Part 4: Supplementary functions. ISO/IEC Technical Specification 18661-4:2015, Geneva, Switzerland, October 2015.

    Google Scholar 

  17. International Organization for Standardization. Floating-point extensions for C – Part 5: Supplementary attributes. ISO/IEC Technical Specification 18661-5:2016, Geneva, Switzerland, August 2016.

    Google Scholar 

  18. W. Kahan and J. Darcy. How Java’s floating-point hurts everyone everywhere. Available at http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf, 1998.

  19. B. W. Kernighan and D. M. Ritchie. The C Programming Language. Prentice-Hall, Englewood Cliffs, NJ, 1978.

    MATH  Google Scholar 

  20. V. Lefèvre. The Euclidean division implemented with a floating-point division and a floor. Research report RR-5604, INRIA, June 2005.

    Google Scholar 

  21. X. Leroy. Formal verification of a realistic compiler. Communications of the ACM, 52(7):107–115, 2009.

    Article  Google Scholar 

  22. T. Lindholm, F. Yellin, G. Bracha, and A. Buckley. The Java TM Virtual Machine Specification, Java SE 8 edition. Oracle, 2015.

    Google Scholar 

  23. D. Monniaux. The pitfalls of verifying floating-point computations. ACM TOPLAS, 30(3):1–41, 2008. A preliminary version is available at http://hal.archives-ouvertes.fr/hal-00128124.

  24. S. Muchnik. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997.

    Google Scholar 

  25. Sun. Numerical Computation Guide – Sun TM Studio 11, 2005. Available at http://docs.sun.com/source/819-3693/.

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer International Publishing AG, part of Springer Nature

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Muller, JM. et al. (2018). Languages and Compilers. In: Handbook of Floating-Point Arithmetic. Birkhäuser, Cham. https://doi.org/10.1007/978-3-319-76526-6_6

Download citation

Publish with us

Policies and ethics