import { AbstractInteger } from './AbstractInteger'; import { VALUE, SPI } from './ops/symbols'; /** * Compare two integers. * * @param a * @param b */ export function compare>(a: I, b: I): -1 | 0 | 1 { const spi = a[SPI]; const aValue = a[VALUE]; const bValue = b[VALUE]; return spi.compare(aValue, bValue); } /** * Get if the given integers are equal. * * @param a * @param b */ export function isEqual>(a: D, b: D): boolean { return compare(a, b) === 0; } /** * Get if the first integer is less than the second one. * * @param a * @param b */ export function isLessThan>(a: D, b: D): boolean { return compare(a, b) < 0; } /** * Get if the first integer is less than or equal to the second one. * * @param a * @param b */ export function isLessThanOrEqual>(a: D, b: D): boolean { return compare(a, b) <= 0; } /** * Get if the first integer is greater than the second one. * * @param a * @param b */ export function isGreaterThan>(a: D, b: D): boolean { return compare(a, b) > 0; } /** * Get if the first integer is greater than or equal to the second one. * * @param a * @param b */ export function isGreaterThanOrEqual>(a: D, b: D): boolean { return compare(a, b) >= 0; }