如何在Jquery中将浮点值舍入为其最接近的整数

ssr*_*srp 2 floating-point int jquery rounding

我想将两个130.68(大于或等于130.5)和131.32(小于131.5)的值舍入到131.

Tus*_*har 6

使用Math.round()

Math.round(130.68); // return 131
Math.round(131.32); // return 131
Run Code Online (Sandbox Code Playgroud)

Fiddle Demo