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

Breadcrumb

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

function BigDecimal::minus

Returns the difference of this number and the given one.

The result has a scale of `max($this->scale, $that->scale)`.

Parameters

BigNumber|int|float|string $that The number to subtract. Must be convertible to a BigDecimal.:

Throws

MathException If the number is not valid, or is not convertible to a BigDecimal.

File

vendor/brick/math/src/BigDecimal.php, line 174

Class

BigDecimal
Immutable, arbitrary-precision signed decimal numbers.

Namespace

Brick\Math

Code

public function minus(BigNumber|int|float|string $that) : BigDecimal {
    $that = BigDecimal::of($that);
    if ($that->value === '0' && $that->scale <= $this->scale) {
        return $this;
    }
    [
        $a,
        $b,
    ] = $this->scaleValues($this, $that);
    $value = Calculator::get()->sub($a, $b);
    $scale = $this->scale > $that->scale ? $this->scale : $that->scale;
    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