Page 1 of 1
Help with this formula!
Posted: Tue Apr 14, 2009 2:44 pm
by thirtyfourtwenty
I have a project that requires a Body Fat Percentage calculator. The formulas I have found are as follows, but when I try to have PHP make the calculation, they don't work. Can someone help with these formulas in PHP?
Formula for Men:
%Fat=495/(1.0324-0.19077(log(waist-neck))+0.15456(log(height)))-450
Formula for Women:
%Fat=495/(1.29579-0.35004(log(waist+hip-neck))+0.22100(log(height)))-450
I tried the formula (for Men), unsuccessfully, using numbers as follows:
495/(1.0324 - .19077(log(31 - 11)) + .15456(log(72))) - 450
Please help! Thanks!!
Re: Help with this formula!
Posted: Tue Apr 14, 2009 3:17 pm
by requinix
You have to use * for multiplication.
Not familiar with programming, are you?
Re: Help with this formula!
Posted: Tue Apr 14, 2009 3:23 pm
by webgrrl
The first thing that I noticed was that you didn't use the operator * for multiplication after .19077 and .15456 remember just because in real math puting something in parathesis after a number means multiplication you have to specify that in a programming language. Think of it this way, when you call a function in PHP you use the syntax myFunction() so instead it is going to look for a function with the name of the number you put there. I haven't tried that exactly because I don't have my scientific calculator on me to check, but see if that works.
Re: Help with this formula!
Posted: Tue Apr 14, 2009 4:16 pm
by requinix
webgrrl wrote:The first thing that I noticed was that you didn't use the operator * for multiplication after .19077 and .15456 remember just because in real math puting something in parathesis after a number means multiplication you have to specify that in a programming language. Think of it this way, when you call a function in PHP you use the syntax myFunction() so instead it is going to look for a function with the name of the number you put there. I haven't tried that exactly because I don't have my scientific calculator on me to check, but see if that works.
For most languages parentheses don't mean anything. They're like commas: you use them for a greater purpose. That includes math: parentheses don't mean anything there either, they're just used for grouping stuff together.
In math if you stick something next to something else without any kind of symbol in between it automatically means multiplication. PHP is not a mathematical language so it won't assume anything.