Why does this whole number have a recurring value?


I have a math question which that may seem simple to some but not to me if you where to do the calculation 12.30 * 12 it would equal 147.60 but why is that when I show the answer to more then two decimal place it has a 2 at the end 147.60000000000002 where did the 2 come from if 12.30 is a whole number ?

Again Im sorry if this sounds dumb but Im curious and thought this is the best place to ask.


Posted 2016-09-06T13:12:56.487

Reputation: 123

Question was closed 2016-09-06T14:32:20.637

4It looks like it is an artifact of how numbers are represented in binary internally. – Per Alexandersson – 2016-09-06T13:20:17.853

Rationalize[12.30]*12 – Feyre – 2016-09-06T13:28:32.977



It's a numerical artifact that is due to finite precision of computer calculations. Indeed, when one computes

SetAccuracy[12.30*12, 15]


It's notable that the input is in decimal system (at least the user thinks of it as such), but the computer uses its binary representation. For example, $\frac{1}{10}$ is an exact number, but 0.1 has an infinite expansion when expressed in binary (i.e., $0.1_{10}=0.000110011001100110011001100110011..._2$; see also here). Hence the computer never uses exactly $\frac{1}{10}$ but a rounded number:

SetAccuracy[0.1, 20]


What you see above in the case of 12.30*12 is most likely a result of such rounding. It should be also noted that in most published materials, when some result is given to e.g. 20 decimal digits, in most cases it is not reasonable: in fact, every machine will give a slightly different output. The computation on two different computers (or different software) can give results different on the 15th or 12th or some other decimal place.


Posted 2016-09-06T13:12:56.487

Reputation: 22 814

Thank you for this makes a lot of sense – MrJoshFisher – 2016-09-06T14:40:14.970