X-Git-Url: https://git.ladys.computer/Pisces/blobdiff_plain/f3e417be2077db5839dcada4aa1395ae2e9337ba..fb3e0d562e2dbe9e3ea911a80bfdabc8851f92b2:/numeric.js?ds=inline diff --git a/numeric.js b/numeric.js index ce92585..64d9a80 100644 --- a/numeric.js +++ b/numeric.js @@ -650,10 +650,10 @@ export const { * Returns the result of converting the provided number to an integer * or infinity. * - * ☡ This function does not allow big·int arguments. + * ※ This function will never return negative zero. */ export const toIntegerOrInfinity = ($) => { - const integer = trunc($); + const integer = trunc(toNumber($)); if (isNan(integer) || integer == 0) { // The provided value truncs to nan or (positive or negative) zero. return 0; @@ -669,6 +669,17 @@ export const toIntegerOrInfinity = ($) => { } }; +/** + * Returns the result of converting the provided number to an integral + * number. + * + * ※ This function will never return negative zero. + */ +export const toIntegralNumber = ($) => { + const n = toIntegerOrInfinity($); + return !isFiniteNumber(n) || n == 0 ? 0 : n; +}; + /** * Returns the result of converting the provided value to a number. *