nickjbedford/decimal
Composer 安装命令:
composer require nickjbedford/decimal
包简介
A custom implementation of a Decimal class wrapping the BC library.
README 文档
README
This library implements the BC Math library into both an immutable and mutable subclass pair of classes named ImmutableDecimal and Decimal (mutable). The classes provide common methods such as simple arithmetic, equality and comparison methods as well as formatting and changes to decimal precision.
Example Usage
Immutable decimal arithmetic
$balance = new \YetAnother\ImmutableDecimal(144.52, 2); $newBalance = $balance->plus(55.95); $newBalance->printValue(); // "200.02" if ($newBalance->greaterThanOrEqual(200)) { print("New balance is at or over $200."); }
Mutable decimal arithmetic (with helpers)
$amount = d4('129.9523'); // 4-digit precision (mutable) Decimal $amount->add(87.5); // addition in place $amount->printValue(); // "217.4523" $remainder = $amount->modulus(5.5); $remainder->printValue(); // "2.9523"
统计信息
- 总下载量: 207
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-16