PHPackages                             timur-flush/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. timur-flush/math

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

timur-flush/math
================

Math wrapper.

v1.3.0(7y ago)0311PHPPHP ^7.2.0

Since Mar 21Pushed 7y agoCompare

[ Source](https://github.com/TimurFlush/Math)[ Packagist](https://packagist.org/packages/timur-flush/math)[ RSS](/packages/timur-flush-math/feed)WikiDiscussions 1.x-dev Synced 3d ago

READMEChangelogDependencies (3)Versions (9)Used By (1)

[![Build Status](https://camo.githubusercontent.com/9bf5ae6961ec39893bd517e5dd40c7b2bcdd9d04fbc34a383aa13bb8d9a6a83e/68747470733a2f2f7472617669732d63692e6f72672f54696d7572466c7573682f4d6174682e7376673f6272616e63683d312e782d646576)](https://travis-ci.org/TimurFlush/Math)[![Coverage Status](https://camo.githubusercontent.com/7e21534536861947452572ddc223ddaff45b2a8f11cd85b9ca733927b0e4deab/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f54696d7572466c7573682f4d6174682f62616467652e7376673f6272616e63683d312e782d646576)](https://coveralls.io/github/TimurFlush/Math?branch=1.x-dev)

Враппер для bcmath.

Если вы используете Composer

```
    php composer.phar require timur-flush/math

```

Или если вы инклюдите руками

```
    require_once 'src/Exception.php';
    require_once 'src/Number.php';
```

```
use TimurFlush\Math\Number as n;

$a = n::create('10.00');

$a->isPositive(); //true
$a->isNegative(); //false

(string)$a->toPositive(); //10.00 new object
(string)$a->toNegative(); //-10.00 new object

# В этих методах последний аргумент scale рассчитывается
# исходя из чисел после точки в обоих числах.
# Но, бывает такое, что результат может обрезаться, т.к.
# в результате чисел после точки может быть больше.
# (советую явно задавать точность(scale) операций)
(string)$a->add('1.00'); //11 new object (плюс)
(string)$a->sub('1.00'); //9 new object (минус)
(string)$a->div('2'); //5 new object (умножение)
(string)$a->mul(2); //20 new object (деление)
(string)$a->pow(2); //100 new object (в степень)
(string)$a->powmod(2, 60); //40 new object (в степень + остаток от деления)
(string)$a->mod(6); //4 new object (остаток от деления)
$a->compare('10') === n::COMPARE_EQUAL; //true (если равен 10)
$a->compare('10') === n::COMPARE_LESS; //false (если меньше 10)
$a->compare('10') === n::COMPARE_MORE; //false (если больше 10)
$a->isLess('10'); //false (если меньше 10)
$a->isMore('10'); //false (если больше 10)
$a->isEqual('10'); //true (если равен 10)

# Здесь scale не ведет себя так как в примерах выше.
(string)$a->round('1.545'); //1 new object
(string)$a->round('1.555'); //2 new object
(string)$a->round('1.555', 2); // 1.56 new object

(string)$a->floor('1.9'); //1 new object
(string)$a->ceil('1.9'); //2 new object

$a->isZero(); //false (если нуль)
$a->isMoreThanZero(); //true (если больше нуля)
$a->isLessThanZero(); //false (если меньше нуля)

$a->afterZero(); //2 (чисел после нуля)
```

Там где возвращается новый объект (отметил как new object) можно вызывать эти же методы.

Если вам нужно вывести число как строку то приведите объект к string

```
echo (string)$object;
```

Requirements
------------

[](#requirements)

PHP ^7.2.0

BCMath

Authors
-------

[](#authors)

Timur Flush. (Developer)

Matt Raines. (Helper from Stackoverflow)

License
-------

[](#license)

New BSD License.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity60

Established project with proven stability

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 ~2 days

Total

7

Last Release

2601d ago

### Community

Maintainers

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

###  Code Quality

TestsCodeception

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/timur-flush-math/health.svg)

```
[![Health](https://phpackages.com/badges/timur-flush-math/health.svg)](https://phpackages.com/packages/timur-flush-math)
```

###  Alternatives

[abelbm/magento2-disablefrontend

Disable Frontend in Magento 2.

3620.2k](/packages/abelbm-magento2-disablefrontend)[daodao97/hyperf-watch

hyperf develop hot reload

226.6k2](/packages/daodao97-hyperf-watch)[headsnet/money-bundle

Integrates moneyphp/money into your Symfony application

1116.2k](/packages/headsnet-money-bundle)[entidi/silverstrap

A Silverstripe theme based on Bootstrap front end framework

111.4k1](/packages/entidi-silverstrap)

PHPackages © 2026

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