Skip to content

Instantly share code, notes, and snippets.

View juuliaans's full-sized avatar

Julián Santa Ana juuliaans

View GitHub Profile
@a-r-m-i-n
a-r-m-i-n / precise_round.js
Created January 28, 2015 14:43
How to round correctly in JavaScript
function sign(num) {
// IE does not support method sign here
if (typeof Math.sign === 'undefined') {
if (num > 0) {
return 1;
}
if (num < 0) {
return -1;
}
return 0;