+/**
+ * Returns the result of converting the provided number to an integer
+ * or infinity.
+ *
+ * ※ This function will never return negative zero.
+ */
+export const toIntegerOrInfinity = ($) => {
+ const integer = trunc(toNumber($));
+ if (isNan(integer) || integer == 0) {
+ // The provided value truncs to nan or (positive or negative) zero.
+ return 0;
+ } else if (integer == POSITIVE_INFINITY) {
+ // The provided value truncs to positive infinity.
+ return POSITIVE_INFINITY;
+ } else if (integer == NEGATIVE_INFINITY) {
+ // The provided value truncs to negative infinity.
+ return NEGATIVE_INFINITY;
+ } else {
+ // The provided value truncs to an integer.
+ return integer;
+ }
+};
+
+/**
+ * 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;
+};
+