Function den #

Get the denominator of a fraction. For a fraction a/b, the function returns b.

The result is always in lowest terms. For example, den(fraction(8, 6)) returns 3n because 8/6 simplifies to 4/3.

For negative fractions like -a/b or a/-b, the denominator is always returned as a positive bigint. The sign is stored in the numerator. So den(fraction(-2, 3)) and den(fraction(2, -3)) both return 3n.

For matrices, the function is evaluated element wise.

Syntax #

math.den(x)

Parameters #

Parameter Type Description
x Fraction | BigNumber | Array | Matrix A fraction, BigNumber, or array with fractions

Returns #

Type Description
bigint | Array | Matrix The denominator of x (in lowest terms)

Throws #

Type | Description —- | ———–

Examples #

math.den(math.fraction(2, 3))   // returns 3n
math.den(math.fraction(8, 6))   // returns 3n
math.den(math.fraction('5/8'))  // returns 8n
math.den(math.fraction(-2, 3))  // returns 3n
math.den(math.fraction(2, -3))  // returns 3n
math.den(math.bignumber('0.5'))  // returns 2n

See also #

num, fraction

History #

Version Comment
v15.2.0 Created
Fork me on GitHub