Skip to content

Instantly share code, notes, and snippets.

@tkphd
Last active May 30, 2018 18:23
Show Gist options
  • Save tkphd/5b57a930d5b4ed46e0a9cac805cfa6d6 to your computer and use it in GitHub Desktop.
Save tkphd/5b57a930d5b4ed46e0a9cac805cfa6d6 to your computer and use it in GitHub Desktop.
markdown sandbox

Test 2: Shuffled Sum

Ideally, the sequence

    1  	     1      1
10× /   + 9× / + 9× / + 9×1 + 9×10 + 9×100 + 9×1000 = 10000.
   1000     100     10

However, due to the same floating point representation problem, variations arise

Similarly, the sequence

   1      1      1      1
8× / + 8× / + 8× / + 9× / + 8×1 + 8×2 + 8×4 + 8×8 = 128.
   16     8      4      2

Floating-Point Representations

  1. David Goldberg, What Every Computer Scientist Should Know About Floating-Point Arithmetic (1991). Concise summary of how the standard floating-point representation works, and pitfalls to avoid.
  2. Donald Knuth, The Art of Computer Programming, Vol. 2, Ed. 3, §4.2.2: Accuracy of Floating Point Arithmetic (1997). Philosophical review of floating-point representations with discussion of the compromises made to arrive at a working standard.
  3. Erik Cheever, Representation of Numbers (2001).
  4. Rick Regan, Why 0.1 Does Not Exist In Floating-Point (2012). Excellent illustration of why round-off error is a necessary evil in the standard representation.
  5. Jeff Arnold, An Introduction to Floating-Point Arithmetic and Computation (2017). Thorough slide deck highlighting problem areas for scientific computing.
  6. Thomas Risse, Better is the Enemy of Good: Unums &emdash; An Alternative to IEEE 754 Floats and Doubles (2017). Concise discussion of an alternative floating-point representation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment