Re: [algogeeks] Re: c program output

2011-02-07 Thread ankit agarwal
Thanq ol... On Mon, Feb 7, 2011 at 8:56 PM, Dave wrote: > @Ankit: Yes. The bug is that the constant in the comparison should > have been written 11.202e0. > > Dave > > On Feb 7, 9:05 am, ankit agarwal wrote: > > But is the bug in the given program > > > > On Mon, Feb 7, 2011 at 8:32 PM, Sha

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Ankit: Yes. The bug is that the constant in the comparison should have been written 11.202e0. Dave On Feb 7, 9:05 am, ankit agarwal wrote: > But is the bug in the given program > > On Mon, Feb 7, 2011 at 8:32 PM, Shalini Sah > > > > > > wrote: > > try dis : > > > #include > > int main() >

Re: [algogeeks] Re: c program output

2011-02-07 Thread Shalini Sah
i tried it n its running On Mon, Feb 7, 2011 at 8:53 PM, Dave wrote: > @Shalini: Did you try it, or are you only speculating? > > Dave > > On Feb 7, 9:02 am, Shalini Sah > wrote: > > try dis : > > #include > > int main() > > { > > float a=11.202; > > if((a-11.202)==0) > >

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Rajeevpodar: Float comparisons are fine, if you do them correctly. In this case, using 11.202e0 instead of 11.202 is correct. And, of course, your comparison is not an one-sided inequality test, but a fuzzy equality test. Dave On Feb 7, 9:14 am, Rajeevpodar wrote: > Float comparison are not rec

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Shalini: Did you try it, or are you only speculating? Dave On Feb 7, 9:02 am, Shalini Sah wrote: > try dis : > #include > int main() > { >     float a=11.202; >     if((a-11.202)==0) >                 printf("Hiii!!!\n"); >     else >         printf("Hello!!!\n"); >     return 0;} > > you will

[algogeeks] Re: c program output

2011-02-07 Thread Dave
@Ankit: The variable a is a float, while the constant 11.202 is a double. When the constant 11.202 was rounded to size float in the assignment, it was (apparently) rounded down. For purposes of the comparison, a was cast to type double, and the added bits were filled with zeros. So (double)a compar