UNPKG

addsearch-search-ui

Version:

JavaScript library to develop Search UIs for the web

14 lines (13 loc) 438 B
export function roundDownToNearestTenth(num) { var len = Math.ceil(Math.log10(num + 1)); if (len === 1) { return 0; } var tenthMultiplier = Math.pow(10, len - 1); return Math.floor(num / tenthMultiplier) * tenthMultiplier; } export function roundUpToNearestTenth(num) { var len = Math.ceil(Math.log10(num + 1)); var tenthMultiplier = Math.pow(10, len - 1); return Math.ceil(num / tenthMultiplier) * tenthMultiplier; }