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

Breadcrumb

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

function BigRational::nd

Creates a BigRational out of a numerator and a denominator.

If the denominator is negative, the signs of both the numerator and the denominator will be inverted to ensure that the denominator is always positive.

@psalm-pure

Parameters

BigNumber|int|float|string $numerator The numerator. Must be convertible to a BigInteger.:

BigNumber|int|float|string $denominator The denominator. Must be convertible to a BigInteger.:

Throws

NumberFormatException If an argument does not represent a valid number.

RoundingNecessaryException If an argument represents a non-integer number.

DivisionByZeroException If the denominator is zero.

File

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

Class

BigRational
An arbitrarily large rational number.

Namespace

Brick\Math

Code

public static function nd(BigNumber|int|float|string $numerator, BigNumber|int|float|string $denominator) : BigRational {
    $numerator = BigInteger::of($numerator);
    $denominator = BigInteger::of($denominator);
    return new BigRational($numerator, $denominator, true);
}

API Navigation

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