Such type of comaparisons should be avoided because of precision loss. This
article desribe it nicely
http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htmmight
be helpful.

On Thu, Feb 2, 2012 at 11:23 PM, atul anand <[email protected]> wrote:

> output actually depends on precision , bcoz 0.3 is double it will give
> more precise than float.
>
> for eg  2.30000000 < 2.30000000877
>
> On Fri, Feb 3, 2012 at 8:52 AM, rahul sharma <[email protected]>wrote:
>
>> the answer would be none....as by default the default type of floating
>> number is double.....so int in if condition x>.3.....x is float and .3 is
>> doble.....store double in 8 bytes and float in 4 bytes acc to turboc ...u
>> will find x>.3 evaluates to false..........
>>
>>
>> On Thu, Feb 2, 2012 at 11:54 PM, apurva gupta <[email protected]>wrote:
>>
>>> #include<stdio.h>
>>>
>>> int main()
>>> {
>>> float x=0.3, y=0.7;
>>>
>>> if(x>0.3)
>>> {
>>>     if(y>0.7)
>>> printf("Y\n\n");
>>> else
>>> printf("X\n\n");
>>> }
>>> else
>>> printf("NONE\n\n");
>>> }
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
 Sharad Dixit
 B.Tech(IT)
 Indian Institute of Information Technology ,Allahabad
-----------------------------------------------------------------------------------------------------------------------------
"We aim above the mark to hit the mark."
~ Ralph Waldo Emerson

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to