ContinuedFractionsSolver
public struct ContinuedFractionsSolver
Continued Fractions can be used to find an
approximation to a given Rational
number
-
Declaration
Swift
public enum FindApproximationError : Error
-
Finds an approximation to a
value
with a difference belowlimit
.Declaration
Swift
public static func findApproximation(of value: Rational, differenceBelowOrEqual limit: Rational) -> Result<Rational, FindApproximationError>
Parameters
value
Rational
number for which an approximation is required.limit
Rational
number that sets the maximum difference between the result andvalue
.Return Value
A
Rational
number which distance tovalue
is below or equal tolimit
. OrFindApproximationError
error.