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

Breadcrumb

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

function BigRational::__construct

Protected constructor. Use a factory method to obtain an instance.

Parameters

BigInteger $numerator The numerator.:

BigInteger $denominator The denominator.:

bool $checkDenominator Whether to check the denominator for negative and zero.:

Throws

DivisionByZeroException If the denominator is zero.

File

vendor/brick/math/src/BigRational.php, line 40

Class

BigRational
An arbitrarily large rational number.

Namespace

Brick\Math

Code

protected function __construct(BigInteger $numerator, BigInteger $denominator, bool $checkDenominator) {
    if ($checkDenominator) {
        if ($denominator->isZero()) {
            throw DivisionByZeroException::denominatorMustNotBeZero();
        }
        if ($denominator->isNegative()) {
            $numerator = $numerator->negated();
            $denominator = $denominator->negated();
        }
    }
    $this->numerator = $numerator;
    $this->denominator = $denominator;
}

API Navigation

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