if(n > 0)
return Math.ceil(n/3.0) * 3;
else if( n < 0)
return Math.floor(n/3.0) * 3;
else
return 3;
More Related Contents:
- I need a Javascript REGEX for Integers between 18 and 140 inclusive [closed]
- How to round to at most 2 decimal places, if necessary?
- Formatting a number with exactly two decimals in JavaScript
- How do I work around JavaScript’s parseInt octal behavior?
- How do you round to 1 decimal place in Javascript?
- How to print a number with commas as thousands separators in JavaScript
- Generating random whole numbers in JavaScript in a specific range
- How to convert a string to an integer in JavaScript?
- Does JavaScript support 64-bit integers?
- How can I round a number in JavaScript? .toFixed() returns a string?
- Is there a way to round numbers into a reader friendly format? (e.g. $1.1k) [closed]
- Get decimal portion of a number with JavaScript
- How does x|0 floor the number in JavaScript?
- Gaussian/banker’s rounding in JavaScript
- Extremely large numbers in javascript
- bitwise AND in Javascript with a 64 bit integer
- Sort an array based on another array of integers
- In jQuery, what’s the best way of formatting a number to 2 decimal places?
- How do I round a number in JavaScript?
- How can I round down a number in Javascript?
- Whats the difference between JS Number.MAX_SAFE_INTEGER and MAX_VALUE?
- Javascript: Round up to the next multiple of 5
- Rounding numbers to 2 digits after comma
- Convert integer into its character equivalent, where 0 => a, 1 => b, etc
- Convert boolean result into number/integer
- How can I round to whole numbers in JavaScript?
- Round a float up to the next integer in javascript
- JavaScript: Round to a number of decimal places, but strip extra zeros
- How do you round to one decimal place in JavaScript?
- Does Javascript handle integer overflow and underflow? If yes, how?