Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > about float
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 25042 of 27343
Post > Topic >>

about float

by =?GB2312?B?uN/B+g==?= <CodeGuy02@[EMAIL PROTECTED] > Mar 21, 2008 at 02:03 AM

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    float j = 1.0f, i =j;
    int n = 0;
    for(; i - j - 1.00f; ++n, j /= 10)
    {
        ;
    }
    printf("%d", n);

    return EXIT_SUCCESS;
}

I supposed the output was 6, because the float's precision is 6, but
as the result, the output is 20.
why?
 




 5 Posts in Topic:
about float
=?GB2312?B?uN/B+g==?= <  2008-03-21 02:03:12 
Re: about float
rlb@[EMAIL PROTECTED] (R  2008-03-21 09:18:20 
Re: about float
Richard Heathfield <rj  2008-03-21 09:22:47 
Re: about float
Martin Ambuhl <mambuhl  2008-03-21 05:55:33 
Re: about float
=?GB2312?B?uN/B+g==?= <  2008-03-21 02:57:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 21:16:10 CDT 2008.