Closed clayton-aldern closed 4 days ago
Good read that the calculation is off! Looking a bit closer, I think it should actually be:
$: pctCoverage = stats.stl_total_acres / (stats.acres * 2) * 100;
which Prettier will rewrite to:
$: pctCoverage = (stats.stl_total_acres / (stats.acres * 2)) * 100;
to try to disambiguate operator order (which, I absolutely needed on this one). As a quick sanity check, I punched the following into Node:
node
Welcome to Node.js v20.12.2.
Type ".help" for more information.
> // Original implementation.
undefined
> (294895.97 / 823718.64) * 2 * 100
71.60114040881726
> // Attempted fix.
undefined
> (294895.97 / 823718.64 * 2) * 100
71.60114040881726
> // Final fix.
undefined
> (294895.97 / (823718.64 * 2)) * 100
17.9002
The last agrees with the numbers you sent in Slack, so I'll push a commit with that change in real quick! Thanks for catching this eagle eyes 🙏
@parkerziegler I think this line should be
$: pctCoverage = (stats.stl_total_acres / stats.acres * 2) * 100;
(i.e. move the 2 inside the parentheses)?