I want to round both 130.68
(greater than or equals 130.5) and 131.32
(less than 131.5) values to 131
.
Asked
Active
Viewed 6,679 times
2

ssrp
- 1,126
- 5
- 17
- 35
-
2[Math.round()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round) – Satpal Apr 04 '14 at 10:20
-
1possible duplicate of [How do I convert a number to an integer in Javascript?](http://stackoverflow.com/questions/596467/how-do-i-convert-a-number-to-an-integer-in-javascript) – Sani Huttunen Apr 04 '14 at 10:23
4 Answers
2
You need to use Math.round(), In example below both statement will alert 131
alert(Math.round(130.68));
alert(Math.round(131.32));

Satpal
- 132,252
- 13
- 159
- 168