xethron / bignum
v0.2.1
2023-08-01 14:56 UTC
Requires
- php: ^7.0 | ^8.0
- ext-bcmath: *
Requires (Dev)
- infection/infection: ^0.25.6
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-12-20 10:06:41 UTC
README
Intelligent wrapper for BCMath.
Why use this library?
BCMath is a great library, but it has some shortfalls. This library aims to address those shortfalls.
Features
- Adds serialisation of numbers:
- Serialises Floats
- Serialises Strings
- Understands Scientific Notation
- Throws exceptions for invalid values
- Adds Rounding
- All results are rounded
Installation
The recommended way to install this is through composer:
composer require "xethron/bignum"
Usage
<?php use Xethron\Bignum\Math; Math::add(7, 3); // 10 Math::subtract('1', '0.000001'); // 0.999999 // Default 20 precision Math::divide(1, 3); // 0.33333333333333333333 // Set precision to 4 decimals $third = Math::divide(1, 3, 4); // 0.3333 // Set precision to 2, resulting in rounding 0.9999 to 1 $one = Math::multiply($third, 3, 2); // 1 Math::round(0.5678); // 1 Math::round(0.16, 1); // 0.2
Contribution Guidelines
Please open any issues for discussion before starting any work to avoid new features not getting approved.
This project follows the Symfony coding standards.
Contributors
Bernhard Breytenbach (@BBreyten)
License
The library is open-sourced software licensed under the MIT license