storing integer in processor

Discussion in 'C' started by kamlesh.m, May 12, 2008.

  1. kamlesh.m

    kamlesh.m New Member

    Joined:
    May 12, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hello Guys and gals

    I have a strange question

    When I write
    int x= 4;
    The datatype x gets stored in 32 bit compiler in the format 0x000 0100 which is basically a binary format.

    but if I use
    float y= 0.7;
    The datatype as usual should be stored in a binary format.
    but if we convert 0.7 to binary the procedure is as follows

    0.7*2 = 1.4;
    0.4*2= 0.8;
    0.8*2 = 1.6;
    0.6*2 = 1.2;
    0.2*2 = 0.4;
    0.4*2 = 0.8;
    .
    .
    .
    .
    .
    .
    .
    .


    which goes in a never ending loop
    So the binary format (user level) of integer y is 0.10110........
    I just want to know the compiler representation of the above number.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice