On Saturday, August 22, 2015 7:40:31 PM walt wrote: > On Sat, 22 Aug 2015 16:57:41 +0200 > hw <[email protected]> wrote: > > > It is a recipe for disaster when you tell > > your computer to print something but it prints something else instead. > > The Android Stagefright exploit is a real-life example of exactly such a > disaster.
That's an integer overflow which is a different thing. That's the same type of bug that brought down the Cluster spacecraft[1]. > The arithmetic comparison in Stagefright was written in C, not perl, > and compared integers instead of floats, but the underlying fault is > the same in each case: programming languages today assume that human > programmers think like machines. > > Until that fundamental flaw is eliminated from all programming > languages, the problem will not go away. That won't happen in my > lifetime, or yours. Neither integer overflows nor floating point's limited precission are flaws in programming languages. The flaws come when the languages are used improperly. A better way to think about floating point is that it's handled more like we handle numbers in our head. For example, if I ask you "how far you live from here?" you'll probably say something like "3 miles", not 3.003221 miles. Because at that scale the inaccuracy is acceptable. Likewise floating points can handle very large and very small numbers by doing the same. They trade between accuracy and range and they do it automagically. Consider that between 1.000000001 and 1.000000002 there's infinity possible values so it would take inifinite memory to store it. 1. https://en.wikipedia.org/wiki/Cluster_%28spacecraft%29 -- Fernando Rodriguez

