Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Numerical problem with pow (http://www.go4expert.com/forums/numerical-pow-t11381/)

Pinturicchio 16Jun2008 14:27

Numerical problem with pow
 
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,


All times are GMT +5.5. The time now is 14:07.