BigRational.Rationalize Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.7

Overload List

Rationalize(Double) Returns the rational number that exactly equals a floating-point real number.
Rationalize(Double, BigInteger) Approximates a real number by a rational number whose numerator and denominator do not exceed the given value.

Rationalize(Double)

Returns the rational number that exactly equals a floating-point real number.
C#
public static BigRational Rationalize(
	double x
)

Parameters

x  Double
A real number.

Return Value

BigRational
The rational number that exactly equals x.

Rationalize(Double, BigInteger)

Approximates a real number by a rational number whose numerator and denominator do not exceed the given value.
C#
public static BigRational Rationalize(
	double x,
	BigInteger maxValue
)

Parameters

x  Double
The number to approximate.
maxValue  BigInteger
The maximum value of the numerator and the denominator of the result.

Return Value

BigRational
The rational number with numerator and denominator less than maxValue that is closest to x.

Exceptions

ArgumentOutOfRangeException

maxValue is less than zero.

ArgumentException

An approximation that satisfies the condition could not be found.

See Also