Question

I'm trying to do the calculation of this formula,

i = (495 / (1.0324 - 0.19077 * (Math.log(76.2 - 25.4)) + 0.15456 * (Math.log(170.18))) - 450);

Instead of giving the correct answer which is 20.6, its showing the wrong answer 9.59!

Then i discovered that the Math.log function is giving wrong output! How to calculate such kinda operation in Android?

Was it helpful?

Solution

I think you want to use the logarithm in base 10, the one you use returns the closest double approximation of the natural logarithm.

So your expression should be :

i = (495 / (1.0324 - 0.19077 * (Math.log10(76.2 - 25.4)) + 0.15456 * (Math.log10(170.18))) - 450);

Output :

20.630024173730078

OTHER TIPS

Javadoc of Math.log: Returns the natural logarithm (base e) of a double value.

Javadoc of Math.log10: Returns the base 10 logarithm of a double value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top