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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 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.
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.
- 4.
VFP stands for “Vector Floating-Point” but the vector mode was removed shortly after its introduction.
- 5.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61399 for instance.
- 6.
The SPARC architecture has instructions for quadruple precision, but in practice, current processors generate traps to compute the results in software.
- 7.
Details on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37845, fixed for GCC 4.9.
- 8.
The C11 standard still does not specify a power function with an integer type as the second argument.
- 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.
When is_iec559 is true, the C++ standard mandates that infinities and NaNs are available.
- 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.
For Python3: https://docs.python.org/3/reference/datamodel.html; For Python2: https://docs.python.org/2/reference/datamodel.html.
- 13.
- 14.
References
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.
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.
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.
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.
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.
F. de Dinechin, E. McIntosh, and F. Schmidt. Massive tracking on heterogeneous platforms. In 9th International Computational Accelerator Physics Conference (ICAP), October 2006.
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.
J. Gosling, B. Joy, G. Steele, G. Bracha, and A. Buckley. The Java Language Specification, Java SE 8 edition. Oracle, 2015.
International Organization for Standardization. Programming Languages – C. ISO/IEC Standard 9899:1999, Geneva, Switzerland, December 1999.
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.
International Organization for Standardization. Programming languages – Fortran – Part 1: Base language. International Standard ISO/IEC 1539-1:2004, 2004.
International Organization for Standardization. Programming Languages – C. ISO/IEC Standard 9899:2011, Geneva, Switzerland, November 2011.
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.
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.
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.
International Organization for Standardization. Floating-point extensions for C – Part 4: Supplementary functions. ISO/IEC Technical Specification 18661-4:2015, Geneva, Switzerland, October 2015.
International Organization for Standardization. Floating-point extensions for C – Part 5: Supplementary attributes. ISO/IEC Technical Specification 18661-5:2016, Geneva, Switzerland, August 2016.
W. Kahan and J. Darcy. How Java’s floating-point hurts everyone everywhere. Available at http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf, 1998.
B. W. Kernighan and D. M. Ritchie. The C Programming Language. Prentice-Hall, Englewood Cliffs, NJ, 1978.
V. Lefèvre. The Euclidean division implemented with a floating-point division and a floor. Research report RR-5604, INRIA, June 2005.
X. Leroy. Formal verification of a realistic compiler. Communications of the ACM, 52(7):107–115, 2009.
T. Lindholm, F. Yellin, G. Bracha, and A. Buckley. The Java TM Virtual Machine Specification, Java SE 8 edition. Oracle, 2015.
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.
S. Muchnik. Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997.
Sun. Numerical Computation Guide – Sun TM Studio 11, 2005. Available at http://docs.sun.com/source/819-3693/.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer International Publishing AG, part of Springer Nature
About this chapter
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
DOI: https://doi.org/10.1007/978-3-319-76526-6_6
Published:
Publisher Name: Birkhäuser, Cham
Print ISBN: 978-3-319-76525-9
Online ISBN: 978-3-319-76526-6
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)