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
@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()
>
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)
> >
@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
@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
@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