From 8bbb835959c4f6ed9156972b06c7471cb1a09a49 Mon Sep 17 00:00:00 2001 From: superbuggy Date: Wed, 23 Oct 2024 15:55:13 -0400 Subject: [PATCH] This is a combination of 2 commits. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 📝 Improve comment 📝 Improve comment --- cvss40.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cvss40.js b/cvss40.js index 2e026cc..849ad50 100644 --- a/cvss40.js +++ b/cvss40.js @@ -35,7 +35,8 @@ function roundToDecimalPlaces(value, decimalPlaces = 1) { // Step 3: Shift the decimal point back by dividing with the same factor const unshiftedValue = (roundedValue / factor); - // Step 4: Re-round the value with an additional buffering step to precent floating point rounding errors in previous step + // Step 4: Re-round the value with an additional buffering step to prevent floating point rounding errors in previous step + // eg. 8.6 - 7.15 will return 1.4499999999999993 rather than 1.45. When this misrepresented, floating-point difference is rounded to one decimal place, this will produce 1.4 which is not correct const reRoundedValue = Math.round(unshiftedValue * reRoundFactor) / reRoundFactor; // Step 5: Ensure the re-rounded has the correct number of decimal places