简体   繁体   中英

what's wrong with my formula?

I'm making a function which returns the body fat composition from below algorithm:

495/(1.0324-0.19077(LOG(waist-neck))+0.15456(LOG(height)))-450 // for men

495/(1.29579-0.35004(LOG(waist+hip-neck))+0.22100(LOG(height)))-450 // for women

I convert it into java language as below:

495/((1.0324f-(0.19077f*(Math.log(_waist-_neck)))+0.15456f*(Math.log(_height))))-450 // for men

and the values are:

_height = 70.86f; // 180cm & 70in
_waist = 35.43f; // 90cm & 35in
_neck = 19.68f; // 50cm & 19in
// values are converted from centimeter

in my way, it returns -25.125 But in http://www.calculator.net/body-fat-calculator.html site, which already is using this algorithm (see below the converter), I put theses values it returns 10.3

what is my wrong? is there any thing lost in my nested formula??

The formula expects the input in centimeters, not inches, and uses base-10 logarithm:

@Test
public void formula() throws Exception
{
    float _height = 180;
    float _waist = 90;
    float _neck = 50;
    double fat = 495/(1.0324f-(0.19077f*(Math.log10(_waist-_neck)))+0.15456f*(Math.log10(_height)))-450;
    System.out.println(fat);
}

Output

10.31526981020346

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM