polyglot / number
PHP Polyglot number
Fund package maintenance!
Other
v1.0.0
2023-09-08 17:54 UTC
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^6.5 || ^7.5 || 8.5 || 9.5
- squizlabs/php_codesniffer: ^3.7
This package is not auto-updated.
Last update: 2024-11-02 21:41:01 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)