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 5,804 times
2
ssrp
- 1,008
- 5
- 16
- 34
-
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 Singh 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
- 129,808
- 12
- 152
- 166