function BigDecimal::ofUnscaledValue
Creates a BigDecimal from an unscaled value and a scale.
Example: `(12345, 3)` will result in the BigDecimal `12.345`.
@psalm-pure
Parameters
BigNumber|int|float|string $value The unscaled value. Must be convertible to a BigInteger.:
int $scale The scale of the number, positive or zero.:
Throws
\InvalidArgumentException If the scale is negative.
File
-
vendor/
brick/ math/ src/ BigDecimal.php, line 67
Class
- BigDecimal
- Immutable, arbitrary-precision signed decimal numbers.
Namespace
Brick\MathCode
public static function ofUnscaledValue(BigNumber|int|float|string $value, int $scale = 0) : BigDecimal {
if ($scale < 0) {
throw new \InvalidArgumentException('The scale cannot be negative.');
}
return new BigDecimal((string) BigInteger::of($value), $scale);
}