Download the PHP package nsfisis/next-after without Composer
On this page you can find all versions of the php package nsfisis/next-after. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nsfisis/next-after
More information about nsfisis/next-after
Files in nsfisis/next-after
Package next-after
Short Description PHP port of java.lang.Math.nextAfter() family
License MIT
Homepage https://github.com/nsfisis/php-next-after
Informations about the package next-after
php-next-after
A PHP library that provides a port of Java's Math.nextAfter() family of functions.
Overview
This library implements IEEE 754 floating-point manipulation functions that return the next representable floating-point number in a given direction:
nextAfter($x, $y)- Returns the adjacent float in the direction of another valuenextUp($x)- Returns the next float toward positive infinitynextDown($x)- Returns the next float toward negative infinity
Requirements
- PHP 8.4 or higher
- Little-endian 64-bit integers
- IEEE 754 double-precision floats (binary64)
The library performs runtime assertions to verify these constraints are met on the current system.
Installation
Exapmles
API Reference
nextAfter(float $x, float $y): float
Returns the floating-point number adjacent to $x in the direction of $y. If $x equals y, returns y.
Special Cases
- If either argument is NaN, the result is NaN
- If both arguments equal,
$yis returned as it is - If
$xisminValue()and$yis greater than$x, the result is positive zero - If
$xis-minValue()and$yis less than$x, the result is negative zero - If
$xis infinity and$yis not,PHP_FLOAT_MAXis returned - If
$xis negative infinity and$yis not,-PHP_FLOAT_MAXis returned - If
$xisPHP_FLOAT_MAXand$yis infinity, infinity is returned - If
$xis-PHP_FLOAT_MAXand$yis negative infinity, negative infinity is returned
nextUp(float $x): float
Returns the floating-point number adjacent to $x in the direction of positive infinity.
This is semantically equivalent to nextAfter($x, INF).
Special Cases
- If
$xis NaN, the result is NaN - If
$xis positive infinity, the result is positive infinity - If
$xis zero, the result isminValue() - If
$xis-minValue(), the result is negative zero - If
$xisPHP_FLOAT_MAX, infinity is returned
nextDown(float $x): float
Returns the floating-point number adjacent to $x in the direction of negative infinity.
This is semantically equivalent to nextAfter($x, -INF).
Special Cases
- If
$xis NaN, the result is NaN - If
$xis negative infinity, the result is negative infinity - If
$xis zero, the result is-minValue() - If
$xisminValue(), the result is positive zero - If
$xis-PHP_FLOAT_MAX, negative infinity is returned
minValue(): float
Returns the minimum representable non-zero floating-point number. Note that this is a subnormal number and is not the same as PHP_FLOAT_MIN, which is the smallest normal number.
License
See the LICENSE file.
Credits
This library is a PHP port of Java's java.lang.Math.nextAfter(), nextUp(), and nextDown() methods.
Reference: Java Math Documentation