polyglot/number

PHP Polyglot number

Fund package maintenance!
Other

v1.0.0 2023-09-08 17:54 UTC

This package is not auto-updated.

Last update: 2024-11-16 21:54:03 UTC


README

A polyglot number.

Install

composer require polyglot/number:^1.0

Using

$number = new \Polyglot\Number\Number('1.20050c3');

$n = $number->number(); // returns 1200.5 (absolute value)
$i = $number->integer(); // returns 1200 (integer digits)
$v = $number->fractionDigits(); // returns 2 (number of visible fraction digits, with trailing zeros)
$w = $number->fractionDigits(false); // returns 1 (number of visible fraction digits, without trailing zeros)
$f = $number->fraction(); // returns 50 (visible fraction digits, with trailing zeros, expressed as an integer)
$t = $number->fraction(false); // returns 5 (visible fraction digits, without trailing zeros, expressed as an integer)
$c = $number->exponent(); // returns 3 (compact decimal exponent value)