1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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