Elementary confusion
Mark McEahern
marklists at mceahern.com
Mon Sep 23 17:38:11 EDT 2002
[Keith]
> I am working through O'Reilly's "Learning Python". I am up to page 33,
> and already I have a problem. The text outlines a cli entry about math
> operators, all really straight forward;
>
> .>>>a=3
> .>>>b=4
> .>>>b/2+a
> 5
> .>>>b/(2.0+a)
> 0.8
>
> This is so straight forward that I wasn't going to type it in, but I
> did anyway, and got instead of '0.8' something I cannot account for. I
> got '0.80000000000000004'.
>
> So after 32 pages, I am already flumoxed. What is going on
This is a FAQ. Please read the FAQ. This has to do with floating point
math:
http://www.python.org/doc/FAQ.html#4.98
// mark
More information about the Python-list
mailing list