https://github.com/php-decimal/ext-decimal
Correctly-rounded, arbitrary precision decimal floating-point arithmetic in PHP
https://github.com/php-decimal/ext-decimal
arbitrary-precision decimal php
Last synced: 26 days ago
JSON representation
Correctly-rounded, arbitrary precision decimal floating-point arithmetic in PHP
- Host: GitHub
- URL: https://github.com/php-decimal/ext-decimal
- Owner: php-decimal
- License: mit
- Created: 2018-10-13T15:46:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-02-05T06:31:46.000Z (almost 2 years ago)
- Last Synced: 2024-12-14T06:01:08.335Z (about 1 year ago)
- Topics: arbitrary-precision, decimal, php
- Language: PHP
- Homepage: https://php-decimal.github.io/
- Size: 357 KB
- Stars: 339
- Watchers: 16
- Forks: 19
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- favorite-link - PHP 7 中的正确舍入,任意精度的十进制浮点运算。
README
# PHP Decimal Extension
[](https://pecl.php.net/package/decimal/1.3.1)
[](https://travis-ci.org/php-decimal/ext-decimal)
[](https://pecl.php.net/package/decimal/2.0.0)
[](https://travis-ci.org/php-decimal/ext-decimal)
[](https://ci.appveyor.com/project/rtheunissen/php-decimal)
Correctly-rounded, arbitrary-precision decimal arithmetic for PHP
## Documentation
See [php-decimal.github.io](https://php-decimal.github.io)
## Requirements
- PHP >= 7.2
- [libmpdec >= 2.4](http://www.bytereef.org/mpdecimal/download.html)
### Installing libmpdec header files
For Fedora:
```shell
sudo dnf install mpdecimal-devel
```
## Install
```
pecl install decimal
```
**Alpha**:
```
pecl install decimal-alpha
```
Windows users can find *.dll* files under [releases](https://github.com/php-decimal/ext-decimal/releases).
## Enable
You can do this temporarily using `php -dextension=decimal.so` or by adding `extension=decimal.so` to your INI. If you manage PHP with [phpbrew](https://github.com/phpbrew/phpbrew), you can use `phpbrew ext enable decimal`.
## Tests
```
php run-tests.php -P -q
```
## Build from source
Build a debug build of ``php-src`` with a prefix as follows:
```shell
./configure --disable-all --enable-debug --prefix /path/to/custom-php/
```
Within the folder of this extension first run ``phpize`` and then
```shell
./configure --with-php-config=/path/to/custom-php/bin/php-config CFLAGS="-Wfatal-errors -Wall -Wpedantic -Wextra -Wno-unused-parameter -Werror"
```
And finally:
```shell
make -jN
```
Where ``N`` is the number of cores available for compilation