Skip to content
Mark Scherer edited this page Nov 28, 2023 · 2 revisions

Alternatives

in PHP ecosystem

It didnt install on Linux/Mac for PHP 7.2+ and as such is too much of a hazzle to get servers to work with this PHP extension. It would be twice as fast as this library, but doesn't seem maintained enough to rely upon for business use cases.

Too specific for money, also too bloated for normal decimal use cases. It is also mangled with Currency handling and alike. Also ships with a lot of specific formatters. For those use cases try that one.

Doesn't come with Composer. Still PHP 5.6 (no scalar typehinting) if that is important.

Uses an interesting scale/precision concept of "keeping the input scale".

BigDecimal on different engines.

More?

See https://packagist.org/?query=decimal

Or add it above.

Differences of this libary and php-decimal extension

  • We use bcmath and thus scale instead of precision.
  • We cannot use +/-/* arithmetic operations, we need to use methods instead.

API level:

  • abs() is absolute()
  • signum() is sign()
  • sub() is subtract()
  • mul() is multiply()
  • div() is divide()
  • rem()/shift()/ln()/exp()/log10() not handled yet
  • parity() not handled yet
  • isEven()/isOdd() not handled yet
  • toFixed() not handled yet

Static level:

  • Decimal::sum(array|Traversable $values, int $precision = 28): Decimal not handled yet
  • Decimal::avg(array|Traversable $values, int $precision = 28): Decimal not handled yet