PHPackages                             ffmg/myoddweb.bignumber.php - 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. ffmg/myoddweb.bignumber.php

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

ffmg/myoddweb.bignumber.php
===========================

Big number with no external dependencies

0.1.603(10y ago)324GPL-2.0PHPPHP &gt;=5.4.0

Since Dec 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/FFMG/myoddweb.bignumber.php)[ Packagist](https://packagist.org/packages/ffmg/myoddweb.bignumber.php)[ Docs](https://github.com/FFMG/myoddweb.bignumber.php)[ RSS](/packages/ffmg-myoddwebbignumberphp/feed)WikiDiscussions master Synced 2w ago

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

myoddweb.bignumber.php
======================

[](#myoddwebbignumberphp)

A php bignumber class that does not have any external dependency. Based on the [myoddweb.bignumber.cpp project](https://github.com/FFMG/myoddweb.bignumber.cpp)

Status
------

[](#status)

[![Build Status](https://camo.githubusercontent.com/1c866fffccb8d877a904876ec8dcb2e0a2f855e0dbf1107d24726bd59f308ca3/68747470733a2f2f7472617669732d63692e6f72672f46464d472f6d796f64647765622e6269676e756d6265722e7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/FFMG/myoddweb.classifier)[![Latest Stable Version](https://camo.githubusercontent.com/4ad8b86d193b6a161c29c27d977ef64f5693169ba80965bf61c85f6eebb14b94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66666d672f6d796f64647765622e6269676e756d6265722e7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ffmg/myoddweb.bignumber.php)[![GitHub license](https://camo.githubusercontent.com/99d280c5a1f6abf3596fc7a96de71d3ae1003f7e99ee55140aae35bb88ba705e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c76322d626c75652e737667)](https://camo.githubusercontent.com/99d280c5a1f6abf3596fc7a96de71d3ae1003f7e99ee55140aae35bb88ba705e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c76322d626c75652e737667)

Usage
=====

[](#usage)

In your project
---------------

[](#in-your-project)

### Composer

[](#composer)

You can install this library using [Composer](https://getcomposer.org/ "Getcomposer").

```
{
    "require": {
        "ffmg/myoddweb.bignumber.php": "0.1.*"
    }
}

```

And then simply include "*require\_once "vendor/autoload.php"*" in your script, (or whatever path you use to composer).

You can also browse the [package directly](https://packagist.org/packages/ffmg/myoddweb.bignumber.php).

### Direct download

[](#direct-download)

Simply include the file "path/to/code/BigNumber.php" in your project.
The other files are just testing and this project.

```
// in your script
include "path/to/code/BigNumber.php"

// use it
$lhs = new \MyOddWeb\BigNumber( 10 );
$lhs = new \MyOddWeb\BigNumber( 10 );
$sum = $lhs->Add( $rhs );	// = 20

// good times...

```

Examples
--------

[](#examples)

```
// without composer
include "path/to/code/BigNumber.php"

// with composer
include "MyOddweb\BigNumber\BigNumber.php"

```

### Simple usage:

[](#simple-usage)

See the various tests for more sample code.

Big numbers using strings

```
// using strings
$x = new \MyOddWeb\BigNumber("18446744073709551615");
$y = new \MyOddWeb\BigNumber("348446744073709551615");
$sum = $x->Add( $y )->ToString();

```

Integers

```
// using int
$x = new \MyOddWeb\BigNumber(17);
$y = new \MyOddWeb\BigNumber(26);
$sum = $x->Add( $y )->ToInt();

```

Doubles

```
// using doubles
$x = new \MyOddWeb\BigNumber(17.0);
$y = new \MyOddWeb\BigNumber(26.0);
$sum = $x->Add( $y )->ToDouble();

```

Convert to another base

```
// output number to base 2.
$x = new \MyOddWeb\BigNumber(5);
$base2 = $x->ToBase( 2 );	// =101 (base 2)

// fraction/real numbers
// output number to base 8 with decimals.
$x = new \MyOddWeb\BigNumber(10.8);
$base2 = x->ToBase( 8, 2 );	// =12.63 (base 8)

```

You can convert from base 2 to base 62

**Operations in one line:**

Integers

```
$x = new \MyOddWeb\BigNumber("17")->Add(\MyOddWeb\BigNumber("26"))->ToInt();

```

Double

```
$x = new \MyOddWeb\BigNumber(1.234)->Add(\MyOddWeb\BigNumber(2.345))->ToDouble();

```

**Create a single item inline**

```
$x = (new \MyOddWeb\BigNumber( 123 ) )->Log( 20 )->Sub(12)

```

or you could do the same without the '***new***' argument.

```
$x = \MyOddWeb\BigNumber( 123 )->Log( 20 )->Sub(12)

```

Functions
=========

[](#functions)

### Math functions

[](#math-functions)

- Add( number ) : Add '*number*' to '*this*' number.
- Sub( number ) : Subtract '*number*' from '*this*' number.
- Mul( number ) : Multiply '*number*' to '*this*' number.
- Div( number ) : Divide '*this*' by '*number*' number.
- Add( number ) : Add '*number*' to '*this*' number.
- Factorial() : The factorial of this number, (!n)
- Mod( number ) : The mod of '*this*' number, (n % m). The remainder of the division.
- Quotient( number ) : : The quotient of dividing '*this*' number with this '*number*'.
- Pow( number ) : '*this*' raised to '*number*' (n \* n \* n \* ...).
    - Negative number.
- Exp() : e raised to the power '*this*'
- Ln() : logarithm base e of '*this*'.
- Root( number ) : The nth root of '*this*' number.
- Sqrt() : The square root of '*this*' number.

### Other functions

[](#other-functions)

- IsNeg() : If '*this*' number is negative or not.
- IsZero() : If '*this*' number is zero or not.
- IsNan() : If '*this*' number is Not a number or not, (NAN). This is the result of divide by zero or negative factorials for example.
- IsOdd() : If '*this*' number is odd.
- IsEven() : If '*this*' number is even.
- Compare( number ) : -ve = smaller / +ve = greater / 0 = same.

    - IsEqual( number ) : If '*this*' is equal to '*number*'.
    - IsUnequal( number ) : If '*this*' is not equal to '*number*'.
    - IsGreater( number ) : If '*this*' is greater than '*number*'.
    - IsLess( number ) : If '*this*' is less than '*number*'.
    - IsGreaterEqual( number ) : If '*this*' is greater or equal to '*number*'.
    - IsLessEqual( number ) : If '*this*' is less or equal to '*number*'.
- IsInteger() : If '*this*' number is a whole number positive or negative.
- ToInt() : convert to int.
- ToDouble() : convert to double.
- ToString() : Output the number as a string, (if you want to limit the number of decimals use the *ToBase( ... )* funtion).
- ToBase( base = 10\[, precision=100\] ) : convert to string.

    - You can pass a base number to convert to, the default is base 10. The allowed bases are **2-62**. The values are **0-9** then **A-Z** then **a-z**
    - You can use the precision to limit the number of decimals been returned in the string output.
- Abs() : Get the absolute value of the number
- Trunc( precision ) : Truncate the number, strip the decimals. (+/-n.xyz = n)
- Ceil( precision ) : Round the number up (2.1 = 3 / -2.1 = -2)
- Floor( precision ) : Round the number down (2.1 = 2 / -2.1 = -3)
- ToDegree( ... ) : convert *this* from a Radian to a Degree given a certain precision.
- ToRadiant( ... ) : convert *this* from a Degree to a Radian given a certain precision.

Constants
---------

[](#constants)

- e() : [Euler's number](https://en.wikipedia.org/wiki/E_%28mathematical_constant%29) (to 150 decimals).
- pi(): [Pi](https://en.wikipedia.org/wiki/Pi), (to 150 decimals).

Todo
====

[](#todo)

see the [myoddweb.bignumber.cpp project](https://github.com/FFMG/myoddweb.bignumber.cpp) as functions are added here after they are added to the cpp project.

###  Health Score

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~8 days

Total

4

Last Release

3867d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5659271?v=4)[FFMG](/maintainers/FFMG)[@FFMG](https://github.com/FFMG)

---

Top Contributors

[![FFMG](https://avatars.githubusercontent.com/u/5659271?v=4)](https://github.com/FFMG "FFMG (69 commits)")

---

Tags

decimalbignumbignumbernumber

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ffmg-myoddwebbignumberphp/health.svg)

```
[![Health](https://phpackages.com/badges/ffmg-myoddwebbignumberphp/health.svg)](https://phpackages.com/packages/ffmg-myoddwebbignumberphp)
```

###  Alternatives

[brick/math

Arbitrary-precision arithmetic library

2.2k564.4M496](/packages/brick-math)[php-decimal/php-decimal

Correctly-rounded arbitrary precision decimal floating point

781.1M11](/packages/php-decimal-php-decimal)[rtlopez/decimal

An object oriented immutable arbitrary-precision arithmetic library for PHP

27279.7k2](/packages/rtlopez-decimal)[prestashop/decimal

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

179.1M9](/packages/prestashop-decimal)[delight-im/base-convert

Conversion of arbitrarily large numbers between any two bases or alphabets

161.7k](/packages/delight-im-base-convert)[thunderer/numbase

Convert any number between arbitrary bases

242.3k](/packages/thunderer-numbase)

PHPackages © 2026

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