Reputation: 2979
I know this maybe very simple and common but I want to know about this calculation:
Example: I have a decimal number 4.716981132075472
, but I only need the 4
number, is there any calculation able to do this?
Upvotes: 0
Views: 83
Reputation:
Try round off:
var result = 4.716981132075472 << 0;
alert(result);
OR
var result = Math.floor(4.716981132075472);
alert(result);
Upvotes: 5
Reputation: 1002
Try Math.floor( 4.716981132075472);
. This rounds the number down to the nearest integer, thus solving your problem.
Upvotes: 1