-
Remove decimals
Hello,
I’ve been trying to simply remove the decimals from a number; eg. I want 9.9 rounded to 9, just killing off everything after the decimal point. So Math.round and toFixed don’t work; they do it “mathematically properly”. I’m trying to divide one number by another, but only want a whole integer result.I remember from the dim and distant past that BBC Basic (from the 1980s!) had a DIV function, that gave “the integer quotient of two items. The result is always an integer”, so 21 DIV 5 would give 4. I assume Javascript must have some equivalent of this? I suppose I could do a workaround and subtract the remainder from the first number:
a=21;
b=4
c=a%b;
(a-c)/b…but that’s a bit of a palaver!
Any other suggestions, please?
Thanks,
Paul