On Fri, Jan 27, 2012 at 2:47 PM, Adam Prescott <adam / aprescott.com> wrote:
> 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.

No smiley here?  I think the expectation of perfection in a human
built is a tad too optimistic.  :-)  The human imperfection infects
everything we do.  But: the good news is that there are systems for
symbolic computations around which in fact do a pretty decent job.  I
had the chance to work with Maple a while ago and personally I find
those beasts amazing.

http://www.mathontheweb.org/mathweb/mi-software.html

> 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.

And thanks to IEEE the model (and thus its limitations) is the same
across a wide range of programming languages.  So the knowledge about
it can be reused when learning a new language.

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/