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

Breadcrumb

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

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

Code

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

API Navigation

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