aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/NextAfter.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/NextAfter.php')
-rw-r--r--src/NextAfter.php13
1 files changed, 10 insertions, 3 deletions
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) :
@@ -77,6 +76,14 @@ final class NextAfter
/**
* @phpstan-pure
*/
+ public static function minValue(): float
+ {
+ return self::intToFloat(1);
+ }
+
+ /**
+ * @phpstan-pure
+ */
private static function intToFloat(int $x): float
{
return self::unpackFloat64(self::packInt64($x));