[Tutor] re: range function

Bruce Sass bsass@freenet.edmonton.ab.ca
Thu, 24 May 2001 12:51:50 -0600 (MDT)


On Thu, 24 May 2001, D-Man wrote:

> On Thu, May 24, 2001 at 12:33:54AM -0600, Bruce Sass wrote:
> | The only problem is I did it while in xemacs, using ^c^c, and the
>
> ^c^c? I thought it was C-c C-c ;-).  (I'm just teasing you, I don't
> remember the emacs keys anymore)

:)

> | Since...
> |
> | >>> 5.5499999999999998 == 5.55
> | 1
> |
> | ...is it anything more than a cosmetic issue when print-ing, e.g., a
> | list of floats (rather than the items in a list of floats).
>
> Yes -- the actual number in memory hasn't changed.  If you look at my
> example I used string interpolation to truncate the numbers at 2
> decimal points when I printed my results.

Right.  What I meant is... if you are using Python's builtin fp, you
know it is limited to binary accuracy, so what should it matter
(computationally) if 5.55 == 5.5499999999999998.  It is only the
display that `looks' off, and then only because python2.x spits out
the repr, and not the str, of floats in a list when "print"-ing the
list.

[Which gets me wondering why it was changed, but's another story.]

> If you want a description of the IEEE 754 floating point
> representation I can give it to you (I had to implement addition,
> subtraction and multiplication on single precision IEEE 754 floats in
> m68k assembly for a lab, but I didn't have enough time to do the
> multiplication)

Naw, thanks though.
I still remember some of the fp stuff I learned way back when I was
doing it on 8-bit machines, so I've got an idea of what's up.  That
kinda thing should be done in assembler anyways... ;)


- Bruce