Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BigDecimal.php

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\Math

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal