Click or drag to resize
Accord.NET (logo)

RationalFromDoubleWithMaxDenominator Method

Converts a floating-point decimal to a rational number.

Namespace:  Accord.Math
Assembly:  Accord (in Accord.dll) Version: 3.8.0
Syntax
public static Rational FromDoubleWithMaxDenominator(
	double value,
	int maxDenominator,
	double tolerance = 1E-06
)
Request Example View Source

Parameters

value
Type: SystemDouble
A floating-point number to convert to a rational number.
maxDenominator
Type: SystemInt32
The maximum value that the denominator can have.
tolerance (Optional)
Type: SystemDouble
The desired maximum error between the result and the input value. This is only used as an alternative end condition; the actual error may be greater because of the limitation on the denominator value.

Return Value

Type: Rational
A rational number.
See Also