From: suresh kanna [mailto:[EMAIL PROTECTED] 

>hai,
>
>Can anyone help me(explain) in this program!
>
>main(){
>float f= 0.7;
>if(f<0.7)
>  {printf("The value less than 0.7");}
>else 
>  printf("The value greater ");
>}
> 
>
>But the output appears as(the value less than 0.7)
>
>why soo?The system reconizess the value as 0.69999..i think 
>so(not sure)
>
>Can anyone help me in this one...and explain y so!

Because 0.7 cannot be exactly represented in a binary format, so the
nearest approximation is stored (in this case it happens to be slightly
less than 0.7)

An example which you may more readily recognise is the fraction 1/3.
THis cannot be exactly represented as a decimal: 0.3333333....

Any (decimal) representation of this number (e.g. 0.333) will always be
less than 1/3.

Similarly with 2/3 = 0.666666.... - any representation will always be
greater (e.g. 0.66667)

Some fractions can be exactly represented in both bases, e.g. 1/8
(0b0.001 or 0.125)

--
PJH

"Real programmers can write assembly code in any language." - Larry Wall








Alderley plc, Arnolds Field Estate, The Downs, Wickwar, Gloucestershire, GL12 
8JD, UK
Tel: +44(0)1454 294556 Fax: +44 (0)1454 299272

Website : www.alderley.com  Sales : [EMAIL PROTECTED] Service : [EMAIL 
PROTECTED]

This email and its contents are confidential and are solely for the use of the 
intended recipient. If you are not the original recipient you have received it 
in error and any use, dissemination, forwarding, printing or copying of this 
email is strictly prohibited. Should you receive this email in error please 
immediately notify [EMAIL PROTECTED]

This email has been scanned for viruses, however you should always scan emails 
with your own systems prior to opening.









------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~-> 

To unsubscribe : [EMAIL PROTECTED]

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4906
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/Programmers-Town/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to