"S. Chris Colbert" wrote:
>
>What a newbie mistake for me to make.
Don't feel too badly about it. Even very experienced programmers get
bitten by this issue. Until someone points it out, it's certainly not
obvious.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
--
http://mail.p
What a newbie mistake for me to make.
I appreciate the replies everyone!
Cheers,
Chris
> On Fri, 27 Nov 2009 17:06:44 +0100, S. Chris Colbert wrote:
> > I would think that second loop should terminate at 9.9, no?
> >
> > I am missing something fundamental?
>
> "What Every Computer Scientist Sh
On Fri, 27 Nov 2009 17:06:44 +0100, S. Chris Colbert wrote:
> I would think that second loop should terminate at 9.9, no?
>
> I am missing something fundamental?
"What Every Computer Scientist Should Know About Floating Point"
http://docs.sun.com/source/806-3568/ncg_goldberg.html
--
Steven
S. Chris Colbert wrote:
> In [15]: t = 0.
>
> In [16]: time = 10.
>
> In [17]: while t < time:
>: print t
>: t += 0.1
>:
>:
> 0.0
> 0.1
> 0.2
> 0.3
On Fri, 2009-11-27 at 17:06 +0100, S. Chris Colbert wrote:
> This seems strange to me, but perhaps I am just missing something:
> I would think that second loop should terminate at 9.9, no?
>
> I am missing something fundamental?
Floating points variables ...
http://en.wikipedia.org/wiki/Floati
"S. Chris Colbert" writes:
>: print t
Try replacing with: print "%0.20f" % t
The thing you're missing is that floating point arithmetic isn't (in
general) exact - but when it's printed it's rounded.
--
http://mail.python.org/mailman/listinfo/python-list
S. Chris Colbert schrieb:
This seems strange to me, but perhaps I am just missing something:
In [12]: t = 0.
In [13]: time = 10.
In [14]: while t < time:
: print t
: t += 1.
:
:
0.0
1.0
This seems strange to me, but perhaps I am just missing something:
In [12]: t = 0.
In [13]: time = 10.
In [14]: while t < time:
: print t
: t += 1.
:
:
0.0
1.0
2.0