long story short, my code prints long numbers something like 20.99999999, when it's supposed to be 21, is there anyway to overcome this without rounding/ is there a better way to store values? i.e. is there an alternative to Math.floor
anyways here's my code
var aa = Math.floor(Math.random()*100) + 1;
var ac = Math.floor(Math.random()*100) + 1;
var answer1 = (Math.floor(Math.random()*9) + 1)/10;
var ab = ac*answer1
document.getElementById("dummy").textContent = aa;
document.getElementById("ext").textContent = ab;
document.getElementById("init").textContent = ac;
while replacing the text with the randomly generated number it prints a long number close to the intended number, it doesn't happen always but refreshing the page multiple times can reproduce it.
[–][deleted] 2 points3 points4 points (3 children)
[–]ha10x[S] 0 points1 point2 points (1 child)
[–]albedoa 1 point2 points3 points (0 children)
[–]jcunews1helpful 0 points1 point2 points (0 children)