webit / bcmath
Object wrapper for PHP BcMath Library
Installs: 44 877
Dependents: 3
Suggesters: 0
Security: 0
Stars: 17
Watchers: 4
Forks: 7
Open Issues: 0
Requires
- php: >=7.1
- ext-bcmath: *
Requires (Dev)
- phpunit/phpunit: ^7.5.20
This package is auto-updated.
Last update: 2024-10-10 17:57:42 UTC
README
This library provides immutable representation of BcMath number supporting all BcMath extension operations (see http://php.net/manual/en/book.bc.php)
Installation
Composer: add the webit/bcmath into composer.json
{ "require": { "php": ">=7.1.0", "webit/bcmath": "^2.0.0" } }
Usage
$num = new BcMathNumber('123.1233'); $result = $num->add('13.22')->mul('3.05'); echo $result . "\n";
Release note
This version 2.0 breaks a backward compatibility. Since now BcMathNumber:
- is marked
final
- constants are marked
private
- works only for PHP >= 7.1
Version 1.1 breaks a backward compatibility. Since now BcMathNumber:
- is immutable (removed setValue method)
- has no instance property scale (removed instance methods getScale / setScale) as number itself can't have a scale
To use previous version see tag 1.0.0 https://github.com/dbojdo/bcmath/tree/1.0.0
Tests
docker-compose run --rm src composer install docker-compose run --rm phpunit