@daysnap/utils
Version:
15 lines (13 loc) • 326 B
JavaScript
// src/roundUpToNearestInteger.ts
function roundUpToNearestInteger(num) {
if (!num) {
return 1;
}
const symbol = num > 0 ? 1 : -1;
num = Math.abs(num);
const magnitude = Math.pow(10, Math.floor(Math.log10(num)));
return Math.ceil(num / magnitude) * magnitude * symbol;
}
export {
roundUpToNearestInteger
};