nsfisis/next-after
Composer 安装命令:
composer require nsfisis/next-after
包简介
PHP port of java.lang.Math.nextAfter() family
关键字:
README 文档
README
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
$ composer require nsfisis/next-after
Exapmles
use Nsfisis\NextAfter\NextAfter; // Get the next representable float after 1.0. $next = NextAfter::nextAfter(1.0, 2.0); // => 1.0000000000000002 // Get the next float toward positive infinity. $up = NextAfter::nextUp(1.0); // => 1.0000000000000002 // Get the next float toward negative infinity. $down = NextAfter::nextDown(1.0); // => 0.9999999999999999
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
nsfisis/next-after 适用场景与选型建议
nsfisis/next-after 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「float」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nsfisis/next-after 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nsfisis/next-after 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nsfisis/next-after 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Converter and wrapping object for a number (float or integer) value
Field for number with restricted count of digits and decimal places
PHP implementation of python's struct module.
Extended PHP types library.
An arbitrary-precision Decimal class type for PHP.
Math calculation, number representation package
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 19
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-18