PHPackages                             mi-la01/kt\_moontoast-math - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mi-la01/kt\_moontoast-math

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mi-la01/kt\_moontoast-math
==========================

A mathematics library, providing functionality for large numbers

1.2.0(10y ago)01.9kApache-2.0PHPPHP &gt;=5.3.3

Since Jan 11Pushed 10y ago1 watchersCompare

[ Source](https://github.com/MI-LA01/kt_moontoast-math)[ Packagist](https://packagist.org/packages/mi-la01/kt_moontoast-math)[ RSS](/packages/mi-la01-kt-moontoast-math/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (5)Used By (0)

Moontoast Math Library
======================

[](#moontoast-math-library)

[![Build Status](https://camo.githubusercontent.com/5a91519ce5ae4c9165f8b80e5fbc9697823b1bfd1ffb5c6e8f51fa3a593e81cb/68747470733a2f2f7472617669732d63692e6f72672f72616d7365792f6d6174682e706e67)](https://travis-ci.org/ramsey/math)

Moontoast\\Math is useful for working with integers that are larger than (or may become larger than, through mathematical computations) PHP's max integer value for a given system. On 64-bit systems, this number is 9223372036854775807. On 32-bit systems, it is 2147483647. When overflowing this boundary, PHP turns the number into a float, reducing precision (see the PHP manual entry for [Integers](http://php.net/manual/en/language.types.integer.php)).

Moontoast\\Math provides an easy-to-use wrapper around the bcmath extension, allowing one to perform mathematical calculations on numeric strings, going well outside the integer range of the system and maintaining arbitrary precision for more precise calculations.

See the `docs/` directory for generated API documentation.

Moontoast\\Math requires PHP 5.3+ and the [bcmath extension](http://php.net/bcmath).

Installation
------------

[](#installation)

The preferred method of installation is via [Packagist](http://packagist.org/), as this provides the PSR-0 autoloader functionality. The following `composer.json` will download and install the latest version of the Moontoast\\Math library into your project:

```
{
    "require": {
        "moontoast/math": "*"
    }
}
```

Examples
--------

[](#examples)

```
$bn = new \Moontoast\Math\BigNumber('9,223,372,036,854,775,808');
$bn->multiply(35);

var_dump($bn->getValue());
var_dump($bn->convertToBase(16));
```

This produces the following output:

```
string(21) "322818021289917153280"
string(18) "118000000000000000"

```

You might want to use BigNumber to work with a UUID, which is an unsigned 128-bit integer. For example:

```
$uuid = \Moontoast\Math\BigNumber::convertToBase10('ff6f8cb0c57d11e19b210800200c9a66', 16);
```

This utility converts the UUID from hexadecimal (base 16) representation to a string representation of the unsigned 128-bit integer in decimal (base 10). You may now create a BigNumber object with it to perform calculations, if you wish.

```
$bn = new \Moontoast\Math\BigNumber($uuid);
echo $bn; // 339532337419071774305803111643925486182
```

License
-------

[](#license)

Copyright © 2013 Moontoast, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~308 days

Total

4

Last Release

3941d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe9c321f17f1d6943fe433efda924bc29eaef8a7c8c8a98282d8f9a9dfa4e32f?d=identicon)[mi-la01](/maintainers/mi-la01)

---

Top Contributors

[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (14 commits)")[![h4cc](https://avatars.githubusercontent.com/u/2981491?v=4)](https://github.com/h4cc "h4cc (2 commits)")

---

Tags

mathbcmath

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mi-la01-kt-moontoast-math/health.svg)

```
[![Health](https://phpackages.com/badges/mi-la01-kt-moontoast-math/health.svg)](https://phpackages.com/packages/mi-la01-kt-moontoast-math)
```

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.1k504.0M277](/packages/brick-math)[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k7.1M40](/packages/markrogoyski-math-php)[phpseclib/bcmath_compat

PHP 5.x-8.x polyfill for bcmath extension

16720.7M17](/packages/phpseclib-bcmath-compat)[prestashop/decimal

Object-oriented wrapper/shim for BC Math PHP extension. Allows for arbitrary-precision math operations.

178.2M5](/packages/prestashop-decimal)[rubix/tensor

A library and extension that provides objects for scientific computing in PHP.

2751.4M5](/packages/rubix-tensor)[aza/math

AzaMath - Anizoptera CMF mathematic component. Arbitrary precision arithmetic (for huge integers; BCMath wrapper) and universal convertor between positional numeral systems (supported bases from 2 to 62 inclusive, and systems with custom alphabet; pure PHP realisation, can use GMP and core PHP functions for speed optimization).

1921.9k1](/packages/aza-math)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
