RedHatProductSecurity / cvss-v4-calculator

CVSS v4.0 calculator
https://redhatproductsecurity.github.io/cvss-v4-calculator/
BSD 2-Clause "Simplified" License
32 stars 22 forks source link

Fix score rouding issue (#48) #49

Closed pandatix closed 7 months ago

pandatix commented 8 months ago

This PR fixes the rounding issue observed by #48.

It makes sure to round on integers rather than decimals thus avoids 0.1 + 0.2 ! =0.3 issues.

bjedwards commented 7 months ago

I would suggest using Math.round(value*10)/10 rather than the multiplication, toFixed. The toFixed solution goes Number *10 -> String -> Number/10. Whereas the Math.round will just be Number -> Number. For our numbers (0 to 10), they should, be the same.

bjedwards commented 7 months ago

Looks good to me!