NuGet Package Rationals

Implementation of rational number arithmetic for .NET with arbitrary precision.

Supported features:

- implicit conversions - rationals integrate seamlessly with other number types
- unlimited precision - rationals use BigInteger inside
- canonical form - each rational can have its canonical form (irreducible fraction where denominator is always positive)
- separate whole and fractional part - any rational number can be separated into a whole part (integer quotient aka result of integer division) and fractional part (reminder of the integral division aka result of modulo operation)
- comparison & equality
- multiple formatting options - ToString("C") (canonical form), ToString("W") (whole + fractional part), or normal fraction format
- continued fraction expansion - expand rational numbers to continued fraction (sequence of coefficients), construct rational numbers from sequence of continued fraction coefficients
- rational number approximation - approximate floating point numbers (decimal, double, float) as rational numbers with customizable tolerance

Example usage:

Rational left = (Rational) 1 / 2;

Rational right = (Rational) 1 / 4;

Rational sum = left + right; // equals to: 3 / 4.

Info

Version: 1.3.3
Author(s): Tomáš Pažourek
Last Update: Tuesday, January 15, 2019
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/tompazourek/Rationals
NuGet Url: https://www.nuget.org/packages/Rationals


Install
Install-Package Rationals
dotnet add package Rationals
paket add Rationals
Rationals Download (Unzip the "nupkg" after downloading)

.NETFramework 4.7
  • No dependencies.
.NETStandard 2.0
  • No dependencies.
net46
  • No dependencies.
netstandard1.4 2 packages depend on this package.


Tags



STATS

must-have-score

3.6

avg-downloads-per-day

14

days-since-last-release

498