Solved

problem with math.log function in vb.net

Posted on 2008-10-19
4
656 Views
Last Modified: 2010-04-21
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
Comment
Question by:JCM0165
  • 3
4 Comments
 
LVL 16

Expert Comment

by:GreymanMSC
Comment Utility
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

Open in new window

0
 
LVL 16

Accepted Solution

by:
GreymanMSC earned 500 total points
Comment Utility
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

Open in new window

0
 
LVL 16

Expert Comment

by:GreymanMSC
Comment Utility
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 Closing Comment

by:JCM0165
Comment Utility
Thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now