We know that 1 divided by 3 is equal to 0.333333333333333333..... ( the 3 goes on and on ) - This is a recurring decimal.
But the second printf gives the answer as 0.33333334326744079589 - which is obviously not true. So the mysterious result in my rank program is just for this.
Sorry, but this result isn't mysterious at all...
First of all, Pelle's C is using the IEEE 754 format for real numbers, just like pretty much any other compiler out there.
For your example, you are using a 'float' to calculate your value. If you would bother to read the documentation, you would see that a float is a "single precision" real number format using only 32bit to represent the number, with a defined precision of only 7 digits. So if you print using printf without a specific width, you will get shown the result in exactly 7 digits. In the second printf you complain about, you explicitly decided to ignore the maximum precision and force an output of 20 digits. Hence, the output after the first 7 digits is garbage by definition.
If you for example change the variable type from a "float" to a "double", which as the name implies is a double precision real number, using 64bits and with a defined precision of 16 digits, you will see that your second printf output changes to 0.33333333333333330301. Though while this still exceeds the usable precision, you will see that only the last 4 digits are now garbage.
You need to realize that
any usage of real math, including such (partially) workarounds like suggested by CommonTater once, will never be possible to be represented in a limited binary format of standard defined data types...
Ralf