Sunday, 15 February 2015

c++ - Write the math expression in C ++ -



c++ - Write the math expression in C ++ -

there problem mathematical look written below:

cin >> value; dividend = tan(fabs(2*value*value + 5 * value - 31.15)) + log(fabs(value*value - 2.5)) / log(5.0); divider = pow(fabs(pow(sin(value*value*value), 2) + fabs(0.33*(log(fabs(value*value - 2.5) / log(5.0))))), 1 / 5.0); result = dividend / divider;

result invalid value. problem?

although have balanced parentheses denominator, or divider if wish, not correctly placed. yves daoust observed, misplaced partition log(5.0).

spacing out subexpression , parenthesization on different lines should help see this:

pow( fabs( pow(sin(value*value*value), 2) + fabs( 0.33 * ( log( fabs(value*value - 2.5) / log(5.0) ) ) ) ) , 1 / 5.0);

also, why represent one-third 0.33, unless casual precision? partition 3 portable...

c++ math

No comments:

Post a Comment