PHPackages                             olegstan/safe-bc-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. olegstan/safe-bc-math

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

olegstan/safe-bc-math
=====================

Safe versions of BC math functions

00PHP

Since Mar 12Pushed 1y agoCompare

[ Source](https://github.com/olegstan/safe-bc-math)[ Packagist](https://packagist.org/packages/olegstan/safe-bc-math)[ RSS](/packages/olegstan-safe-bc-math/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Safe BC Math
============

[](#safe-bc-math)

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

[](#installation)

```
$ composer require backendtea/safe-bc-math
```

Why this package
----------------

[](#why-this-package)

Casting a float to a string does not always do what you think it does. Some locales may give unexpected results, and give a malformed string, or the number is cast to a scientific notationm for example: `1.0E-11`. Which bcmath cant handle. Even if you do not manually cast it to a string, the bc math functions expect strings, and will cast it themselves.

This package will throw an exception telling you what error it encountered, instead of giving a warning `bcmath function argument is not well-formed` and returning a wrong error.

Usage
-----

[](#usage)

Replace any usage of bc math functions with the `Backendtea\bc..` version.

e.g.

```
- bcadd($a, $b);
+ \BackEndTea\bcadd($a, $b);
```

Or even better, import the funtion:

```
+ use function BackEndTea\bcadd;

bcadd($a, $b);
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f8bd26c5b9a18189abe0c2d2b252fade1fad4838b9dcb72c5b82b8ec803de6e5?d=identicon)[olegstan](/maintainers/olegstan)

---

Top Contributors

[![olegstan](https://avatars.githubusercontent.com/u/6509570?v=4)](https://github.com/olegstan "olegstan (3 commits)")[![BackEndTea](https://avatars.githubusercontent.com/u/14289961?v=4)](https://github.com/BackEndTea "BackEndTea (2 commits)")

### Embed Badge

![Health badge](/badges/olegstan-safe-bc-math/health.svg)

```
[![Health](https://phpackages.com/badges/olegstan-safe-bc-math/health.svg)](https://phpackages.com/packages/olegstan-safe-bc-math)
```

PHPackages © 2026

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