Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
4 of 4 added 7 characters in body

Your argumentation against floating point numbers is very fragile, probably because of naivety. (No offense here, I find your question is actually very interesting, I hope my answer will also be.)

A classic argument is that floats provide a greater range, but high precision integers can meet this challenge now. For example: with modern 64-bit processors, we can do fast integer calculations up to 2^64. The solar system is a little less than 10 billion km in width. 10 billion km divided by 2^64 is about 5 microns. Isn't being able to represent position within the solar system to the precision of half a human hair enough?

You seem to make an implicit statement, according to which once we know the scale of our problem, we can use fixed point arithmetic with respect to this scale to solve that problem.

Sometimes, this is a valid approach, and this is the one picked by Knuth to implement distance computations in TeX. What makes the use of fixed point arithmetic pertinent in this case is that all quantities appearing within a computation are either integers or distances occurring in a typesetting problem. Because the field of applications is so narrow, it makes sense to choose a very small unit length, much smaller than what the human eye can perceive, and to convert all quantities into multiples of this unit. This leads to a very important result: in the typographical problems relying on this representation of numbers, we never need to multiply two lengths together, so that loss of precision caused by multiplications in fixed point arithmetic do not occur.

Most of the times, it is however a terrible approach, here are a few reasons why:

  1. There exists physical constants and you cannot always adapt their units in a sensible way.

    Consider your solar system setting. The gravitational constant is 6.67×10−11 N·(m/kg)2, the speed of light is 3.00x10+5 m/s, the mass of the Sun is 1.9891×10+30 kg and the mass of the Earth is 5.97219×10+24. In your fixed point setting, you will not be able to represent the gravitational constant to a satisfying precision. So you will change the unit. But by doing so, you have to replace each number—replacing well-known, familiar quantities, by cryptic values. Furthermore, it is very likely that finding a system to appropriately represent all constants you need might not even be possible. Think to quantum physicits working with infinitely small particles whose speed is near the speed of light.

  2. There exists mathematical unitless constants.

    The value of Pi 3.1415 (up to the 4th decimal place) without any unit attached. There is actually a lot of similar useful constants that cannot be accurately represented in an arbitrary fixed point system. In the solar system setting you described, we can represent Pi with 6 decimal places, which gives a terrible accuracy when computing the circumference of a planet orbit, for instance.

  3. In a fixed point system, we need to know in advance the size of the quantity you are computing.

    Assume that we still do not know the value of the gravitational constant. We would make a lot of measures and write a computer program to find an approximation of that constant. Unfortunately, in the solar system setting you described, the gravitational constant is represented by 0, which should be the, rather useless, result of our

  4. Some mathematical functions will not work well with fixed precision arithmetic, because of their growth rate.

    The most important ones are the exponential and the gamma function, which practically means that every program working with anything else than polynomials will be flawed.

  5. In fixed point arithmetic, it is very hard to multiply and divide numbers correctly.

    This is because if we do not know a priori the size of the numbers, we cannot tell if their product will fit in the representation. That is, we would have to check manually for precision underflow before each multiplication.


While the conclusion of your question implies that fixed point arithmetic could be sufficient for all-purpose computations and that floating point arithmetic should be reserved to supercalculators, it is precisely the converse which is true: floating point arithmetic is a very good and very sensible tool for all-purpose computations, while fixed point will only do well in very specific, well analysed, cases.