On 01/-10/-28163 02:59 PM, Steven D'Aprano wrote:
Alan Gauld wrote:
Why would you use a loop when the final value is just
the final multiplication. Since you know the final value
in advance (you need it to create the loop!) why not
just do the final multiplication directly:
x = 10*0.1
I think
> >> The right way is to do it like this:
> >>
> >> >>> x = 0.0
> >> >>> for i in range(1, 11):
> >> ... x = i*0.1
> > But this I don't understand.
> > Why would you use a loop when the final value is just
>
> What you missed was the original context, where other work was being
> done in
> Some further resources:
>
> http://floating-point-gui.de/
> http://introcs.cs.princeton.edu/91float/
>
> David Goldberg used to have a fantastic (although quite technical)
> discussion of floating point issues, "What Every Computer Scientist Should
> Know About Floating-Point Arithmetic":
>
> htt
On 01/-10/-28163 02:59 PM, Alan Gauld wrote:
"Steven D'Aprano" wrote
The right way is to do it like this:
>>> x = 0.0
>>> for i in range(1, 11):
... x = i*0.1
...
>>> x == 1.0
True
But this I don't understand.
Why would you use a loop when the final value is just
the final multiplicati
Alan Gauld wrote:
Why would you use a loop when the final value is just
the final multiplication. Since you know the final value
in advance (you need it to create the loop!) why not
just do the final multiplication directly:
x = 10*0.1
I think I'm missing something?
The context was generatin
"Steven D'Aprano" wrote
Another problem: you calculate your values by repeated addition.
This is the wrong way to do it, because each addition has a tiny
little error, and repeating them just compounds error upon error.
Here's an example:
>>> x = 0.0
>>> for i in range(10):
... x += 0.
Am 11.03.2011 06:05, schrieb Steven D'Aprano:
Alex Hall wrote:
Hi all,
I am trying to get a list of ordered pairs from the below function. In
my code, evaluate is more exciting, but the evaluate here will at
least let this run. The below runs fine, with one exception: somehow,
it is saying that
Am 11.03.2011 04:23, schrieb Alex Hall:
Hi all,
I am trying to get a list of ordered pairs from the below function. In
my code, evaluate is more exciting, but the evaluate here will at
least let this run. The below runs fine, with one exception: somehow,
it is saying that -2+2.0 is 4.x, where x i
Alex Hall wrote:
Hi all,
I am trying to get a list of ordered pairs from the below function. In
my code, evaluate is more exciting, but the evaluate here will at
least let this run. The below runs fine, with one exception: somehow,
it is saying that -2+2.0 is 4.x, where x is a huge decimal involv
Hi all,
I am trying to get a list of ordered pairs from the below function. In
my code, evaluate is more exciting, but the evaluate here will at
least let this run. The below runs fine, with one exception: somehow,
it is saying that -2+2.0 is 4.x, where x is a huge decimal involving
E-16 (in other
10 matches
Mail list logo