1function float2int (value) {
2 return value | 0;
3}
4
5float2int(3.75); //3 - always just truncates decimals
6
7//other options
8Math.floor( 3.75 );//3 - goes to floor , note (-3.75 = -4)
9Math.ceil( 3.75 ); //4 - goes to ceiling, note (-3.75 = -3)
10Math.round( 3.75 );//4
1// x = Number.MAX_SAFE_INTEGER/10 * -1 // -900719925474099.1
2
3// value = x // x=-900719925474099 x=-900719925474099.5 x=-900719925474099.6
4
5Math.floor(value) // -900719925474099 -900719925474100 -900719925474100
6Math.ceil(value) // -900719925474099 -900719925474099 -900719925474099
7Math.round(value) // -900719925474099 -900719925474099 -900719925474100
8Math.trunc(value) // -900719925474099 -900719925474099 -900719925474099
9parseInt(value) // -900719925474099 -900719925474099 -900719925474099
10value | 0 // -858993459 -858993459 -858993459
11~~value // -858993459 -858993459 -858993459
12value >> 0 // -858993459 -858993459 -858993459
13value >>> 0 // 3435973837 3435973837 3435973837
14value - value % 1 // -900719925474099 -900719925474099 -900719925474099
15