import { type MinAndMaxFunctionResult, type SortCompareFunction } from '../sort'; import { type MapFunction } from '../value/map'; import { type Maybe } from '../value/maybe.type'; /** * A non-negative integer representing a count of items. * * @example * ```ts * const totalUsers: Count = 42; * ``` * * @semanticType * @semanticTopic numeric */ export type Count = number; /** * A string represented within a number. * * @semanticType * @semanticTopic numeric * @semanticTopic string */ export type NumberString = string; /** * Number that represents a percent. * * e.g. PercentNumber of 5 = 0.05 = 5% * * @semanticType * @semanticTopic percent * @semanticTopic numeric */ export type PercentNumber = number; /** * A percent decimal value. * * e.g. PercentDecimal of 0.05 = 5% * * @semanticType * @semanticTopic percent * @semanticTopic numeric */ export type PercentDecimal = number; /** * Converts a {@link PercentNumber} (e.g., 5 for 5%) to its decimal equivalent (e.g., 0.05). * * Returns 0 for null/undefined input. * * @param input - A percent number value (e.g., 5 means 5%) * @returns The decimal equivalent. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, percent, decimal, convert, ratio * @dbxUtilRelated percent-number-from-decimal */ export declare function percentNumberToDecimal(input: Maybe): number; /** * Converts a {@link PercentDecimal} (e.g., 0.05 for 5%) to its {@link PercentNumber} equivalent (e.g., 5). * * Returns 0 for null/undefined input. * * @param input - A decimal percent value (e.g., 0.05 means 5%) * @returns The percent number equivalent. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, percent, decimal, convert, ratio * @dbxUtilRelated percent-number-to-decimal */ export declare function percentNumberFromDecimal(input: Maybe): PercentNumber; export type NumberOrNumberString = number | NumberString; /** * Reads a number from the input value. */ export type ReadNumberFunction = MapFunction; /** * asNumber() input */ export type AsNumberInput = Maybe; /** * Converts a number, string, or null/undefined value to a number. * * Strings are parsed via `Number()`. Null/undefined returns 0. * * @param input - Numeric value, numeric string, or null/undefined. * @returns The numeric value, or 0 for null/undefined. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, parse, convert, coerce, string, normalize */ export declare function asNumber(input: AsNumberInput): number; /** * Checks whether the input value is evenly divisible by the divisor. * * Treats null/undefined as 0. * * @param value - The number to check. * @param divisor - The divisor to test against. * @returns `true` if the remainder is zero. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, divisible, modulo, division, math, check * @dbxUtilRelated nearest-divisible-values, is-even-number, is-odd-number */ export declare function isNumberDivisibleBy(value: Maybe, divisor: number): boolean; export interface NearestDivisibleValues { value: number; divisor: number; nearestCeil: number; nearestFloor: number; } /** * Finds the nearest values that are evenly divisible by the divisor, both above (ceil) and below (floor) the input value. * * @param value - The value to find divisible neighbors for. * @param divisor - The divisor to align to. * @returns Object with the input value, divisor, and the nearest ceil/floor divisible values. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, divisible, nearest, ceil, floor, round, snap, math * @dbxUtilRelated is-number-divisible-by */ export declare function nearestDivisibleValues(value: number, divisor: number): NearestDivisibleValues; /** * Checks whether the input is an even number. * * @param value - Number to test. * @returns `true` if even. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, even, parity, math, check * @dbxUtilRelated is-odd-number, is-number-divisible-by */ export declare function isEvenNumber(value: number): boolean; /** * Checks whether the input is an odd number. * * @param value - Number to test. * @returns `true` if odd. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, odd, parity, math, check * @dbxUtilRelated is-even-number, is-number-divisible-by */ export declare function isOddNumber(value: number): boolean; /** * Computes the sum of all integers between two values, inclusive, using Gauss's formula. * * The `from` value is floored and the `to` value is ceiled before computation. * * @param from - The starting value (floored to nearest integer) * @param to - The ending value (ceiled to nearest integer) * @returns Sum of all integers in the range. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, sum, range, integers, math, gauss, total */ export declare function sumOfIntegersBetween(from: number, to: number): number; /** * A {@link SortCompareFunction} for numbers that sorts in ascending order. * * @param a - The first number to compare. * @param b - The second number to compare. * @returns A negative value if `a` is less than `b`, zero if equal, or a positive value if `a` is greater. */ export declare const sortCompareNumberFunction: SortCompareFunction; /** * Finds the minimum and maximum values from an iterable of numbers. * * @param values - Iterable of numbers to examine. * @returns Object with `min` and `max` values. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, min, max, range, sort, bounds, extremes * @dbxUtilRelated sort-compare-number-function */ export declare function minAndMaxNumber(values: Iterable): MinAndMaxFunctionResult; /** * Computes the logarithm of `y` with base `x`. * * @param x - The base of the logarithm. * @param y - The value to compute the logarithm of. * @returns The base-x logarithm of y. * * @dbxUtil * @dbxUtilCategory number * @dbxUtilTags number, log, logarithm, math, base * * @example * ```ts * getBaseLog(2, 16); // 4 (2^4 = 16) * getBaseLog(10, 100); // 2 (10^2 = 100) * ``` */ export declare function getBaseLog(x: number, y: number): number;