#Demystifying Floating Point John Farrier, CPPCon 2015
Slides and Source Code from "Demystifying Floating Point Numbers" given at CPPCon 2015.
##Notes
- IEEE Single Format - 1 sign, 8 exponent, 23 fraction
- IEEE Double Format - 1 sign, 11 exponent, 52 fraction
- Has several rounding options (Java only permits "Round to Nearest")
- Do not test for equality
- Order of operations matters
- The relative magnitudes of numbers involved in a computataion matters
- Prefer to multiply, add, and subtract - divide only when necessary
- Avoid elementary functions i.e. logarithmic, exponential, trigonometric, hyperbolic
##General Online References
- A Logarithm Too Clever by Half
- Anatomy of a floating point number
- Comparing Floating Point Numbers
- Demystifying Floating Point
- Don't Store That in a Float
- Five Tips for Floating Point Programming
- Floating Point Comparison
- Floating Point Determinisim
- Floating point number representation
- Floating Point Operations and Streaming SIMD Extensions
- Floating Point Representation
- Floating Point
- IEEE 754 Converter
- IEEE floating-point exceptions in C++
- Is floating point math deterministic?
- Is Your Model Susceptible to Floating-Point Errors?
- Lecture Notes on the Status of IEEE 754, Kahan, October 1, 1997
- Mathematics in Video Games
- Miscalculating Area and Angles of a Needle-like Triangle
- Visualizing Floats
- We Really Don't Know How To Compute!
- What Every Computer Scientist Should Know About Floating-Point Arithmetic
##General Offline References
- Hacker's Delight, (Warren)
- Handbook of Floating-Point Arithmetic (Muller, Brisebarre)
- Numerical Computing with IEEE Floating Point Arithmetic (Overton)
##Compiler Specific Information ###Visual Studio Microsoft Visual C++ Floating-Point Optimization https://msdn.microsoft.com/library/aa289157.aspx
####Compiler Flags
- /fp:[precise | except[-] | fast | strict ]
####Pragmas
- float_control( value,setting [push] | push | pop )
- fenv_access [ON | OFF]
- fp_contract [ON | OFF]
###GCC Math_Optimization_Flags Semantics of Floating Point Math in GCC https://gcc.gnu.org/wiki/FloatingPointMath https://gcc.gnu.org/wiki/Math_Optimization_Flags
####Compiler Flags
- -ffinite-math-only
- -fno-rounding-math
- -fno-signaling-nans
- -fno-signed-zeros
- -fnotrapping-math
- -frounding-math
- -fsignaling-nans
- -funsafe-math-optimizations
- -funsafe-math-optimizations