function BigDecimal::withPointMovedRight
Returns a copy of this BigDecimal with the decimal point moved $n places to the right.
1 call to BigDecimal::withPointMovedRight()
- BigDecimal::withPointMovedLeft in vendor/
brick/ math/ src/ BigDecimal.php - Returns a copy of this BigDecimal with the decimal point moved $n places to the left.
File
-
vendor/
brick/ math/ src/ BigDecimal.php, line 468
Class
- BigDecimal
- Immutable, arbitrary-precision signed decimal numbers.
Namespace
Brick\MathCode
public function withPointMovedRight(int $n) : BigDecimal {
if ($n === 0) {
return $this;
}
if ($n < 0) {
return $this->withPointMovedLeft(-$n);
}
$value = $this->value;
$scale = $this->scale - $n;
if ($scale < 0) {
if ($value !== '0') {
$value .= \str_repeat('0', -$scale);
}
$scale = 0;
}
return new BigDecimal($value, $scale);
}