July 20–24, 2015
Portland, OR

What every programmer should know about floating-point arithmetic

Joe Darcy (Oracle)
11:30am–12:10pm Wednesday, 07/22/2015
Solve E147/148
Average rating: ****.
(4.80, 5 ratings)
Slides:   external link

Prerequisite Knowledge

Basic knowledge of C or Java to understand short code examples.


Why doesn’t

0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 = 1.0?

Why is it correct for 0.1f = 0.1d to be false?

IEEE 754 floating-point arithmetic is commonly used in processors and in programming languages, but often has surprising results. This talk will describe how floating-point arithmetic is a systematic approximation to real arithmetic, explain limitations to the approximation, and provide lessons to keep in mind for floating-point programming.

Particular examples will be drawn from C and Java.

Photo of Joe Darcy

Joe Darcy


Joe Darcy is a long-time developer in the JDK engineering group who as “Java Floating-Point Czar” has looked after Java numerics, amongst other responsibilities. Joe was involved with the design of Java’s strictfp floating-point semantics, added numerous floating-point math library methods to the platform, helped expand BigDecimal support, and added hexadecimal floating-point literals to the Java language and library. Joe was a participant in and interim editor for the IEEE 754r working group to revise the IEEE 754 floating-point standard.