Bignum
A smart wrapper for bcmath that allows
Install / Use
/learn @Xethron/BignumREADME
Bignum library for PHP
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
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
