On Mon, Dec 2, 2013 at 4:49 PM, eryksun wrote:
> On Mon, Dec 2, 2013 at 1:28 AM, Amit Saha wrote:
>> Indeed, that's a good point. Surprisingly, C does it just fine:
>>
>> # include
>>
>> int main(int argc, char **argv)
>> {
>> float x = 0.0;
>> while(x<1)
>> {
>> x += 0.1;
>>
On 02/12/2013 12:27, Dave Angel wrote:
On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote:
Indeed, that's a good point. Surprisingly, C does it just fine:
# include
int main(int argc, char **argv)
{
float x = 0.0;
while(x<1)
{
x += 0.1;
printf("%f\n", x);
}
On Mon, 2 Dec 2013 22:57:30 +1000, Amit Saha
wrote:
You missed the fact that I am printing the value of x *after*
incrementing it.
You're quite right, sorry. I'm too accustomed to the usual c idiom,
which would increment the value at the end of the loop.
--
DaveA
On Mon, Dec 2, 2013 at 10:27 PM, Dave Angel wrote:
> On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha wrote:
>>
>> Indeed, that's a good point. Surprisingly, C does it just fine:
>
>
>
>> # include
>
>
>
>> int main(int argc, char **argv)
>> {
>> float x = 0.0;
>> while(x<1)
>> {
>> x
On Mon, 2 Dec 2013 16:28:38 +1000, Amit Saha
wrote:
Indeed, that's a good point. Surprisingly, C does it just fine:
# include
int main(int argc, char **argv)
{
float x = 0.0;
while(x<1)
{
x += 0.1;
printf("%f\n", x);
}
return 0;
}
gives the following ou
On Mon, Dec 02, 2013 at 04:28:38PM +1000, Amit Saha wrote:
> On Sun, Dec 1, 2013 at 7:26 PM, Steven D'Aprano wrote:
> > Such floating point loops are tricky to get right, thanks to rounding of
> > floats. Observe:
> >
> > py> x = 0.0
> > py> while x < 1.0:
> > ... x += 0.1
> > ...
> > py> x =
On Mon, Dec 2, 2013 at 1:28 AM, Amit Saha wrote:
> Indeed, that's a good point. Surprisingly, C does it just fine:
>
> # include
>
> int main(int argc, char **argv)
> {
> float x = 0.0;
> while(x<1)
> {
> x += 0.1;
> printf("%f\n", x);
> }
>
> return 0;
> }
Python uses
On Mon, Dec 2, 2013 at 4:36 PM, Asokan Pichai wrote:
> On Mon, Dec 2, 2013 at 11:58 AM, Amit Saha wrote:
>>
>> On Sun, Dec 1, 2013 at 7:26 PM, Steven D'Aprano
>> wrote:
>> > On Sun, Dec 01, 2013 at 07:03:15PM +1000, Amit Saha wrote:
>> >> Hello,
>> >>
>> >> Much to my disbelief, I realized I had
On Sun, Dec 1, 2013 at 7:47 PM, spir wrote:
> On 12/01/2013 10:03 AM, Amit Saha wrote:
>>
>> Hello,
>>
>> Much to my disbelief, I realized I hadn't written a program in Python
>> as far as I can recall which required me to do something like this, in
>> psuedocode:
>>
>> x = 0.1
>>
>> for i = 0 to
On Sun, Dec 1, 2013 at 7:14 PM, Dominik George wrote:
> Hi,
>
>> - Do not create a list of the floating point values as i=[0.01, 0.02,
>> 0.03..] - either like that or by using a suitable mathematical formula
>> combined with a list comprehension
>
> You could simply write your own version of xran
On Sun, Dec 1, 2013 at 7:26 PM, Steven D'Aprano wrote:
> On Sun, Dec 01, 2013 at 07:03:15PM +1000, Amit Saha wrote:
>> Hello,
>>
>> Much to my disbelief, I realized I hadn't written a program in Python
>> as far as I can recall which required me to do something like this, in
>> psuedocode:
>>
>> x
On 12/01/2013 10:03 AM, Amit Saha wrote:
Hello,
Much to my disbelief, I realized I hadn't written a program in Python
as far as I can recall which required me to do something like this, in
psuedocode:
x = 0.1
for i = 0 to x step 0.01
# do something with i
end i
Simply stated, I want to start
On 01/12/2013 09:14, Dominik George wrote:
Hi,
- Do not create a list of the floating point values as i=[0.01, 0.02,
0.03..] - either like that or by using a suitable mathematical formula
combined with a list comprehension
You could simply write your own version of xrange that does it, as a
g
On Sun, Dec 01, 2013 at 07:03:15PM +1000, Amit Saha wrote:
> Hello,
>
> Much to my disbelief, I realized I hadn't written a program in Python
> as far as I can recall which required me to do something like this, in
> psuedocode:
>
> x = 0.1
>
> for i = 0 to x step 0.01
> # do something with i
>
Hi,
> - Do not create a list of the floating point values as i=[0.01, 0.02,
> 0.03..] - either like that or by using a suitable mathematical formula
> combined with a list comprehension
You could simply write your own version of xrange that does it, as a
generator:
def xrange_f(start, stop, st
Hello,
Much to my disbelief, I realized I hadn't written a program in Python
as far as I can recall which required me to do something like this, in
psuedocode:
x = 0.1
for i = 0 to x step 0.01
# do something with i
end i
Simply stated, I want to start from say a value, 0 and go upto 0.1 in
incr
16 matches
Mail list logo