-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumericFunctions.js
More file actions
39 lines (37 loc) · 883 Bytes
/
NumericFunctions.js
File metadata and controls
39 lines (37 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Checks if passed value is numeric. Integers or decimals accepted as numeric.
* @param value
* @returns {boolean}
* @constructor
*/
function IsNumeric(value) {
return !isNaN(value);
}
/**
* Rounds up to the specified step, default is 1. (e.g. value = 4.3 step = 0.5 returns 4.5)
* @param value
* @param step
* @returns {number}
* @constructor
*/
function RoundUpTo(value, step) {
step || (step = 1)
var remainder = value % step;
if (remainder > 0)
value = value - remainder + step;
return value;
}
/**
* Rounds down to the specified step, default is 1. (e.g. value = 4.3 step = 0.5 returns 4)
* @param value
* @param step
* @returns {number}
* @constructor
*/
function RoundDownTo(value, step) {
step || (step = 1)
var remainder = value % step;
if (remainder > 0)
value = value - remainder;
return value;
}