Skip to content

Instantly share code, notes, and snippets.

@benprew
Created August 6, 2021 06:01
Show Gist options
  • Save benprew/7ae8fae988b04ed6bcae1c66287c2944 to your computer and use it in GitHub Desktop.
Save benprew/7ae8fae988b04ed6bcae1c66287c2944 to your computer and use it in GitHub Desktop.
bodyfat calculator
#!/bin/bash
height=$1
neck=$2
abdomen=$3
if [[ -z $height || -z $neck || -z $abdomen ]]; then
echo "$0 - calculate your bodyfat using the US Navy method"
echo "Usage: $0 <height> <neck> <abdomen>"
echo " height - height (in inches)"
echo " neck - neck diameter (in inches, just above adam's apple)"
echo " waist - waist diameter (in inches, narrowest point)"
exit 1
fi
bodyfat=$(echo "86.010 * (l($abdomen - $neck)/l(10)) - 70.041 * (l($height)/l(10)) + 36.76" | bc -l)
printf "bodyfat: %0.0f%%" $bodyfat
@benprew
Copy link
Author

benprew commented Aug 6, 2021 via email

@prewdigy
Copy link

prewdigy commented Aug 6, 2021

they take the average of the set of measurements then use that to calculate it. and they measure your neck, then you stomach, then you neck and so forth.

also considering how much you normally work out. i wouldn't put a lot of faith in it for giving you a decent level of exactness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment