lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Aug 11, 2013, at 4:55 PM, Lorenzo Donati <lorenzodonatibz@tiscali.it> wrote:
> 
> Of course I will highly value good pointers and references to easy
> tutorials that explains how FP work. Admittedly the Goldman paper is
> tough reading for most undergraduates. I myself never quite understood
> it in the details, but at least it gave me a sound sense of paranoia
> (pun intended :-)
> that reemerges every time I have to do non-toy algorithms involving many
> FP calculations!
> 
> @Andrew too:
> 
> The bottom ground is that the newbie may have false expectations: when a
> novice dev approaches FP numbers his mental model is probably that of
> real numbers, whereas FP numbers are a far nastier beast.
> 
> The problem lies, IMHO, also in the fact that when you use integers on a
> computer they seem to work like true (math) integers, beside some
> "quirks" (e.g. overflows) that you rarely see when you just "play" with
> them, as most newbies do.
> 
> So it is easy for a newbie to apply the same approach to FP numbers
> (again - false expectations), and be very puzzled when simple operations
> lead to funny results (how would you explain to a newbie why 1.0 + 1e-15
> result *could* be equal to 1.0 without talking about the gory details of
> FP at least a little?)

Good points. In some ways, I would argue that this whole debate *could* be about the merits of combining integer and floating point into a single "number" type in Lua. As you note, you are lulled into over-confidence with the well-behaved integer model, then pow! .. floating point comes along and students get terrified of even the simplest thing. Keeping float and integer distinct does provide a way to corral the problem and let students know clearly when they are in the "safe haven" of integers. Just thinking out loud, I'm not advocating anything in particular.

--Tim