• Status: Solved
• Priority: Medium
• Security: Public
• Views: 677

# problem with math.log function in vb.net

I am not sure if I am using the math.log function in vb.net properly.

I am trying to do the formula
%Fat=495/(1.0324-0.19077(log(waist-neck))+0.15456(log(height)))-450
(and converting inches to cm)
with
LbJP.Text = 495 / (1.0324 - 0.19077 * (Math.Log((Val(TxtWaistBL.Text) * 2.54) - (Val(TxtNeck.Text) * 2.54))) + 0.15456 * (Math.Log((Val(TxtHeight.Text) * 2.54)))) - 450
but the number isn't coming out anywhere near close to where it should.

High points for expediency! I need an answer quickly
0
JCM0165
• 3
1 Solution

Commented:
The Body Fat Calculation uses base 10 logarithm, where as Math.Log gives the Natural Logarithm.  They are not the same thing.

To convert to base 10 log, you need to divide by the natural log of 10.
``````  LbJP.Text = 495 / (1.0324 - 0.19077 * (Math.Log((Val(TxtWaistBL.Text) * 2.54)/Math.Log(10) - (Val(TxtNeck.Text) * 2.54))) + 0.15456 * (Math.Log((Val(TxtHeight.Text)/Math.Log(10) * 2.54)))) - 450
``````
0

Commented:
Duh...
``````LbJP.Text = 495 / (1.0324 - 0.19077 * (Math.Log((Val(TxtWaistBL.Text) * 2.54) - (Val(TxtNeck.Text) * 2.54))/Math.Log(10)) + 0.15456 * (Math.Log((Val(TxtHeight.Text) * 2.54))/Math.Log(10))) - 450
``````
0

Commented:
Make sure the bracketing around the logs is in the right place.

The important thing is that:

Log10(X) = Math.Log(X) / Math.Log(10)
0

Author Commented:
Thanks!
0

## Featured Post

• 3
Tackle projects and never again get stuck behind a technical roadblock.