Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: arithmetic

15 views
Skip to first unread message

WJ

unread,
Oct 26, 2012, 2:14:38 AM10/26/12
to
Barry Margolin wrote:

> Did the original poster ever take any computer science classes, or
> is he self-taught? If he's taken programming classes, I feel bad
> about the state of CS education these days. ISTR that the problems
> with floating point were taught in our high school programming
> classes, and most introductory programming texts mentioned it. They
> had simple exercises in BASIC like:
>
> FOR I = 1 TO 2 BY .1
> PRINT I
> END

Probably more like:

FOR I = 1 TO 2 STEP .1
PRINT I
NEXT

>
> (I'm pretty sure that's incorrect BASIC syntax -- it's been almost 20
> years since I've used that language) which showed the failure.
>
> The only language I've encountered that tries to hide the problem of
> comparing floating point numbers is APL. It has a "fuzz factor"
> parameter, and turns equality comparisons into comparing if the
> difference is less than this epsilon. Most other languages depend on
> the programmer to do this explicitly when necessary.

Some programming languages used binary-coded-decimal
floating-point, which is able to represent 0.1 exactly.
For example, Decimal BASIC.
0 new messages