2

I want to round both 130.68(greater than or equals 130.5) and 131.32(less than 131.5) values to 131.

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
  • 1
    possible 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 Answers4

7

Use Math.round()

Math.round(130.68); // return 131
Math.round(131.32); // return 131

Fiddle Demo

Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
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));

DEMO

Satpal
  • 132,252
  • 13
  • 159
  • 168
1

You can use Math.round

num=130.68; 
Math.round(num);
1

use this link:

Use Math.round()

sathya
  • 1,404
  • 2
  • 15
  • 26