In both Number::getSuffixNotation() and MagnitudeSuffix::__toString(), the nearest SI magnitude is computed using:
It would be convenient if either Number or MagnitudeSuffix could provide such information.
In my case I am using PHP's round() with negative precision parameter to round a given number to k, M, G, etc. without any decimal part:
$suffixed = Number::n(
round(
$input_number,
-1 * (3 * floor(Number::n($input_number)->getMagnitude()/3))
)
)
->getSuffixNotation();
In both
Number::getSuffixNotation()andMagnitudeSuffix::__toString(), the nearest SI magnitude is computed using:It would be convenient if either
NumberorMagnitudeSuffixcould provide such information.In my case I am using PHP's
round()with negativeprecisionparameter to round a given number to k, M, G, etc. without any decimal part: