On my calculator when I do 18/7 I get 2.5714285714285714285714285714286. From my super limited Math skills 2 is the quotient and .5714285714285714285714285714286 is the remainder.
How can I model this in JavaScript?
Thanks!
var floatingPointPart = (18/7) % 1;
var integerPart = Math.floor(18/7);
Math.floor has the problem of rounding of the result to wrong direction in case of negative number it would be better to use bitwise operation to obtain interger quotients.
var quot = ~~(num/num1)
Hopefully this works for you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With