From e0c0a48051530b82c164ea25a806ba8c38eeb3d5 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 19 Oct 2025 00:12:56 +0900 Subject: feat: add minValue() --- src/NextAfter.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/NextAfter.php') diff --git a/src/NextAfter.php b/src/NextAfter.php index e2b7706..678de25 100644 --- a/src/NextAfter.php +++ b/src/NextAfter.php @@ -11,7 +11,6 @@ use function pack; use function unpack; use const INF; use const NAN; -use const PHP_FLOAT_MIN; use const PHP_INT_SIZE; final class NextAfter @@ -46,7 +45,7 @@ final class NextAfter return INF; } if ($x === 0.0) { - return PHP_FLOAT_MIN; + return self::minValue(); } $u = self::floatToInt($x); return $x > 0.0 ? self::intToFloat($u + 1) : @@ -66,7 +65,7 @@ final class NextAfter return -INF; } if ($x === 0.0) { - return -PHP_FLOAT_MIN; + return -self::minValue(); } $u = self::floatToInt($x); return $x > 0.0 ? self::intToFloat($u - 1) : @@ -74,6 +73,14 @@ final class NextAfter } + /** + * @phpstan-pure + */ + public static function minValue(): float + { + return self::intToFloat(1); + } + /** * @phpstan-pure */ -- cgit v1.2.3-70-g09d2