In javascript, the modulus operator is used to obtain the remainder of a mathematical expression. The result obtained is always an integer. What is the function that is to be used to obtain the exact decimal value remainder in this case?
This is working just fine using the %
operator:
console.log(12.5 % 10) // 2.5
console.log(10 % 5.5) // 4.5
For a reference, also see the MDN article on the remainder operator, outlining this behavior.
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