Correctly coded formulas can still return wrong results, developer warns
A developer building a zero-dependency JavaScript library of health and fitness formulas discovered that many widely used implementations produce plausible but incorrect outputs without any error signals. Common pitfalls include using the wrong coefficient set, feeding metric inputs into imperial equations, and rounding intermediate values before a final calculation — all of which silently return believable wrong numbers. The author argues that tests must also verify their own premises remain valid, since a test whose underlying conditions quietly change can keep passing while checking nothing meaningful. A further lesson emerged when the US Navy body-fat formula — correctly implemented and well-tested — became outdated after the US Department of Defense replaced it with a waist-to-height ratio screen, effective across all services by July 2026. The experience illustrates that a formula can be both technically correct and practically wrong if the real-world standard it represents has changed.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in