I am iterating through a loop, and iterating not by an integer but by a
decimal value, in this case 0.00025. However, after a number of
iterations, the value is off by 0.00000000000001. What's the best way to
round this back to the nearest 10-E5, or does it not matter???
Values such as 0.00025 and many of its multiples are not exactly
representable in double.
Using double for loop control is generally a VERY bad idea. Rounding
errors tend to accumulate. Loop conditions become fuzzy.
It is much better to use an integer for the loop control, and calculate
the value of a double variable from it, e.g. double d = 0.00025*i;
Re: lambda closure question ... > What I want to do is pre-load functions with arguments by iterating... setattr(myclass, item, lamdba self: func(self, item)) ... And that's the correct explanation,... > reference will always get modified as the loop iterates.... (comp.lang.python)
Re: Iterate through member variables of a class ... I did that because the OP was asking about iterating through member ... variables of a class by using a while loop.... you can add or remove elements from the array and the ... So it would be better if I declared the int as a size_t instead? ... (comp.lang.cpp)
Re: looping questions ... this is not a perl problem. ... what is wrong with my IF loop?... You don't want to use scalar glob here. ...iterating over that result. ... (comp.lang.perl.misc)
Re: Holding Returned Data in Arrays ... whether or not new items are available whilst you loop depends on the ... implementation of the thing you are iterating.... In the case of Getfiles() you can see that it returns an array.... (microsoft.public.dotnet.framework.clr)
Re: Another question about performance ... Just a simple iterating 10,000,000 of int in intgive u such ... Not on my box - iterating through 10,000,000 ints using foreach... want to do *something* with the value inside the loop...... (microsoft.public.dotnet.languages.csharp)