On Fri, Jan 27, 2012 at 04:13, Marc Heiler <shevegen / linuxmail.org> wrote:

> x = 1.1
>
> Then i assume that x will be exactly 1.1
>
> That would even by MY own principle of least surprise.
>
> Now I read that, due to the way how Floats are handled on
> computers, this is only an approximation.
>
> And I am sad. Because it shows that computers are not perfect
> at all.
>

It's a direct consequence of trying to fit certain numbers into a binary
representation. You can work through this without a computer at all, just
the mathematics around trying to fit certain numbers into fixed-length
representations in some model; the computer is actually incidental here, to
an extent.

If it weren't 1.1 but were instead an irrational, such as sqrt(2), would
you still think it's a failure of a computer that you can't store its
infinite, non-recurring digits into a computer?

The mathematics behind it *is* precise. It's just that you're assuming one
finite mathematical model to be an infinite model catered to matching
symbolic manipulation. Is that mismatch unexpected to absolute beginners?
Most likely. Once you understand the model, though, there's nothing bizarre
happening. You haven't lost some intrinsic beauty. It's the model.