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?
答案 0 :(得分:1)
使用%
运算符可以正常工作:
console.log(12.5 % 10) // 2.5
console.log(10 % 5.5) // 4.5

有关参考,另请参阅MDN article on the remainder operator,概述此行为。