= 0. * * @param float|int $number */ public static function validateNotNegative($number, ?string $except = null): void { if ($number >= 0) { return; } throw new Exception($except ?? Functions::NAN()); } /** * Confirm number > 0. * * @param float|int $number */ public static function validatePositive($number, ?string $except = null): void { if ($number > 0) { return; } throw new Exception($except ?? Functions::NAN()); } /** * Confirm number != 0. * * @param float|int $number */ public static function validateNotZero($number): void { if ($number) { return; } throw new Exception(Functions::DIV0()); } public static function returnSign(float $number): int { return $number ? (($number > 0) ? 1 : -1) : 0; } public static function getEven(float $number): float { $significance = 2 * self::returnSign($number); return $significance ? (ceil($number / $significance) * $significance) : 0; } /** * Return NAN or value depending on argument. * * @param float $result Number * * @return float|string */ public static function numberOrNan($result) { return is_nan($result) ? Functions::NAN() : $result; } }