Numerical problem with pow

Discussion in 'C' started by Pinturicchio, Jun 16, 2008.

  1. Pinturicchio

    Pinturicchio Banned

    Joined:
    Jun 16, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I have to extract some information from a string:
    an example of the string is
    2.005000+3 is 2005
    1.001000+3 is 1003
    and so on

    So I wrote the following
    /*******************************/
    strncpy(str_Mant,found_string,9);
    strncpy(str_Exp,found_string+9,2);
    Exp_d=atof(str_Exp);
    Mant_d=atof(str_Mant);

    ZAID=Mant_d*pow(10,Exp_d);
    /*******************************/

    It works fine except when the string is
    1.001000+3

    then I get
    1000 instead of 1001
    Exp_d is 3
    Mant_d is 1.001
    as they should be

    any suggestion?
    thanks a lot,
     

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