I’m trying to use the pow function in c++ but the result is not what I expect. Snippet:
#include <math.h>
float floatcopy = boost::lexical_cast<float>(copy); //Then floatcopy is 2.300000
float exponent = boost::lexical_cast<float>(copy[foundEXP+1]); // Then exponent is 5.00000
floatcopy = pow(floatcopy*10,-exponent);
Now, when typing 2.3*10^-5 on my calculator (or in my head..) I get as expected: 0.0000230
The above snipped results in 1.5536773e-007
What is the problem here??
Your calculater is calculating 2.3*(10^-5). In your code you calculate (2.3*10)^-5.