Skip to content

Instantly share code, notes, and snippets.

@Airtnp
Created December 28, 2018 15:53
Show Gist options
  • Save Airtnp/0ba2b91e817eeb24362227547f4ff503 to your computer and use it in GitHub Desktop.
Save Airtnp/0ba2b91e817eeb24362227547f4ff503 to your computer and use it in GitHub Desktop.
Floating number quiz
Originated from http://pdinda.org/Papers/ipdps18.pdf
a, b != NaN, a b are floating numbers
a + b = b + a ? True
a + b + c = a + (b + c) ? False
a(b + c) = ab + ac ? False
(a + b) - a = b ? False (Inf, rounding)
a * a >= 0 ? True (but false for integer arithmetic => overflow)
a overflows ? saturation, Inf (integer => wrap-around)
a := 1, b := 0, a / b = ? (Inf, will propagate to ordinary numeric)
a := 0, b := 0, a / b = ? (NaN)
now a, b can be NaN
a == a ? False (NaN)
a := 0, b := 0, a = b ? False (negative zero)
is a + 1 = a possible ? (Inf, rounding with large magnitude a)
a >> 0, a has larger precision ? True (denomralized)
a + b can has less precision than a and b ? True (rounding)
MADD is part of IEEE standard ? True (new one)
Flush to zero (Intel FTZ, DAZ eliminates denormalized number and gradual underflow), so hardware is on by default
-O2 preservers standard-compliant floating point (-ffast-math, or -Ofast)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment