01

A famous oddity

Type 0.1 plus 0.2 into many programming languages and the answer comes back as 0.30000000000000004. The computer is not broken, and the error is tiny, showing up only in the seventeenth decimal place. But it surprises nearly every new programmer, and it can matter. The cause lies in how computers store numbers with fractions. Most use a format called floating point, standardised in 1985 as IEEE 754 and now built into virtually every processor. It is fast and handles an enormous range of values, from the size of an atom to the distance between galaxies. The price of that range is that most decimal fractions are stored only approximately.

02

Why one tenth is a problem

In our decimal system, some fractions never end: one third is 0.3333 and so on forever, because 3 does not divide neatly into powers of ten. Binary has the same problem with different numbers. Binary fractions are built from halves, quarters, eighths and so on, so only fractions whose denominator is a power of two come out exactly. One tenth is not one of them. Written in binary it becomes 0.000110011001100... repeating forever. A standard 64-bit floating-point number keeps about 53 binary digits, roughly 15 to 17 significant decimal digits, and rounds the rest. The stored value of 0.1 is therefore very slightly more than one tenth.

03

How small errors appear

Each rounding error is minuscule, but arithmetic can expose or accumulate them. Adding the approximate 0.1 to the approximate 0.2 gives a total that rounds to a different binary number from the approximate 0.3, so a test asking whether the two are equal returns false. Add AED 0.10 ten times using ordinary floating point and the result is 0.9999999999999999, not 1. Programmers learn never to compare such numbers for exact equality but to check whether they are close enough. Over millions of repeated operations, such as in long scientific simulations, errors can grow, and numerical analysts design calculations in a careful order specifically to keep that drift under control.

04

When rounding became serious

The most cited example involves a Patriot missile battery in Dhahran, Saudi Arabia, during the 1991 Gulf War. Its software counted time in tenths of a second and stored one tenth in a limited binary format, introducing a minute error at every tick. According to a US government investigation, after about 100 hours of continuous operation the accumulated clock error had reached roughly a third of a second, enough to misjudge where an incoming Scud missile would be. The system failed to intercept it, and the missile struck a barracks, killing 28 soldiers. The flaw had been identified and a fix was already on its way. It arrived a day later.

05

How money is handled instead

Financial software avoids the problem by not storing money as binary fractions. A common approach is to count in the smallest unit: a balance of AED 125.50 becomes the whole number 12,550 fils, and whole numbers are stored exactly. Another is to use decimal arithmetic, available in many programming languages and databases, which stores digits in base ten as an accountant would. Rounding still happens, for example when interest is calculated, but it follows explicit rules, such as rounding half to even or always rounding a fee upwards, set by policy or regulation. That makes every result reproducible, auditable and identical on every computer.

06

Spreadsheets and everyday tools

Spreadsheets generally use binary floating point underneath while showing a rounded display, typically up to 15 significant digits. That usually hides the issue, but it can surface when a formula checks whether two calculated values are equal, or when a total that should be exactly zero shows a tiny remainder in scientific notation. Using a rounding function before comparing values avoids most surprises. The broader lesson is that every computer number is a representation with limits, whether in precision, as here, or in size, as with dates that overflow. Floating point remains the right tool for science, graphics and engineering. For money, exactness matters more than range.

FOLLOW THE EVIDENCE

Sources & further reading

Figures are rounded and widely published; check the linked organisations for the latest editions. These organisations do not endorse this website.