BigRational Structure

Represents an arbitrary rational number.

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
C#
[SerializableAttribute]
public readonly struct BigRational : IComparable, 
	IFormattable, IEquatable<BigRational>, IComparable<BigRational>, 
	IComparable<BigInteger>, IComparable<int>, INumberBase<BigRational>, 
	IParsable<BigRational>, ISpanFormattable, ISpanParsable<BigRational>, 
	IUtf8SpanFormattable, IUtf8SpanParsable<BigRational>, IAdditionOperators<BigRational, BigRational, BigRational>, 
	IAdditiveIdentity<BigRational, BigRational>, IDecrementOperators<BigRational>, 
	IDivisionOperators<BigRational, BigRational, BigRational>, IEqualityOperators<BigRational, BigRational, bool>, 
	IIncrementOperators<BigRational>, IMultiplicativeIdentity<BigRational, BigRational>, 
	IMultiplyOperators<BigRational, BigRational, BigRational>, ISubtractionOperators<BigRational, BigRational, BigRational>, 
	IUnaryNegationOperators<BigRational, BigRational>, IUnaryPlusOperators<BigRational, BigRational>
Inheritance
Object  →  ValueType  →  BigRational
Implements
IComparable, IComparable<BigRational>, IComparable<BigInteger>, IComparable<Int32>, IEquatable<BigRational>, IFormattable, IParsable<BigRational>, ISpanFormattable, ISpanParsable<BigRational>, IUtf8SpanFormattable, IUtf8SpanParsable<BigRational>, IAdditionOperators<BigRational, BigRational, BigRational>, IAdditiveIdentity<BigRational, BigRational>, IDecrementOperators<BigRational>, IDivisionOperators<BigRational, BigRational, BigRational>, IEqualityOperators<BigRational, BigRational, Boolean>, IIncrementOperators<BigRational>, IMultiplicativeIdentity<BigRational, BigRational>, IMultiplyOperators<BigRational, BigRational, BigRational>, INumberBase<BigRational>, ISubtractionOperators<BigRational, BigRational, BigRational>, IUnaryNegationOperators<BigRational, BigRational>, IUnaryPlusOperators<BigRational, BigRational>

Remarks

Use the BigRational class to represent a fraction of integers of arbitrary precision. BigRational objects are immutable.

The Numerator and Denominator return the parts of the fraction. The numerator and the denominator have no common divisors. The denominator is always positive. Zero is represented as 0 / 1.

Constructors

BigRational(BigInteger) Constructs a new BigInteger from two arbitrary precision integers.
BigRational(BigInteger, BigInteger) Constructs a new BigRational from an arbitrary precision numerator and denominator.
BigRational(Int32, Int32) Constructs a new BigRational from an integer numerator and denominator.

Properties

Denominator Gets the denominator of the rational number.
IsOne Gets whether the rational number is equal to one.
IsZero Gets whether the rational number is equal to zero.
Numerator Gets the numerator of the rational number.
Sign Gets the sign of the rational number.

Methods

Abs Returns the absolute value of a rational number.
Add Adds two rational numbers.
Ceiling Rounds a rational number up to the nearest integer.
CompareTo(BigInteger) Compares this instance to a specified rational number and returns an indication of their relative values.
CompareTo(BigRational) Compares this instance to a specified rational number and returns an indication of their relative values.
CompareTo(Int32) Compares this instance to a specified rational number and returns an indication of their relative values.
Deconstruct Deconstructs a rational number into its numerator and denominator.
Divide Divides a rational number by another and returns the result.
Equals(BigRational) Returns whether two rational numbers represent the same value.
Equals(Object) Returns whether this instance is equal to a specified object.
(Overrides ValueType.Equals(Object))
Floor Rounds a rational number down to the nearest integer.
GetHashCode Returns the hash code for this instance.
(Overrides ValueType.GetHashCode())
GetTypeGets the Type of the current instance.
(Inherited from Object)
IsNegativeDetermines if a value represents a negative real number.
IsPositiveDetermines if a value represents zero or a positive real number.
Max Returns the largest of two rational numbers.
MaxMagnitudeCompares two values to compute which has the greater magnitude.
Min Returns the smallest of two rational numbers.
MinMagnitudeCompares two values to compute which has the lesser magnitude.
Multiply(BigInteger, BigRational) Multiplies a rational number by an arbitrary precision integer.
Multiply(BigRational, BigInteger) Multiplies a rational number by an arbitrary precision integer.
Multiply(BigRational, BigRational) Multiplies two rational numbers.
Multiply(BigRational, Int32) Multiplies a rational number by an integer.
Multiply(Int32, BigRational) Multiplies a rational number by an integer.
Negate Negates a rational number from another and returns the result.
Parse(ReadOnlySpan<Char>, IFormatProvider)Parses a span of characters into a value.
Parse(String, IFormatProvider)Parses a string into a value.
Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)Parses a span of characters into a value.
Parse(String, NumberStyles, IFormatProvider)Tries to parse a string into a value.
Pow Raises a BigRational to an integer power.
Reciprocal Returns the reciprocal (inverse) of a rational number..
Round(BigRational) Rounds a rational number to the nearest integer.
Round(BigRational, Int32) Rounds a rational number to the specified number of decimal digits.
ScaleByPowerOfTwo Multiplies a BigRational value by a power of two.
Subtract Subtracts a rational number from another and returns the result.
ToString() Returns a string representation of the rational number.
(Overrides ValueType.ToString())
ToString(String, IFormatProvider) Returns a string representation of a rational number.
Truncate Rounds a rational number towards zero.
TryFormatTries to format the value of the current instance into the provided span of characters.
TryParse(ReadOnlySpan<Char>, IFormatProvider, BigRational)Tries to parse a span of characters into a value.
TryParse(String, IFormatProvider, BigRational)Tries to parse a string into a value.
TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, BigRational)Tries to parse a span of characters into a value.
TryParse(String, NumberStyles, IFormatProvider, BigRational)Tries to parse a string into a value.

Operators

Addition(BigInteger, BigRational) Adds a big integer and a rational number.
Addition(BigRational, BigInteger) Adds a big integer and a rational number.
Addition(BigRational, BigRational) Adds two rational numbers.
Addition(BigRational, Int32) Adds an integer and a rational number.
Addition(Int32, BigRational) Adds an integer and a rational number.
Decrement(BigRational)Decrements a value.
Division(BigRational, BigInteger) Divides a rational number by an arbitrary precision integer.
Division(BigRational, BigRational) Divides a rational number by another and returns the result.
Division(BigRational, Int32) Divides a rational number by an arbitrary precision integer.
Equality(BigRational, BigInteger) Determines if a rational number is equal to another and returns the result.
Equality(BigRational, BigRational) Determines if a rational number is equal to another and returns the result.
Equality(BigRational, Int32) Determines if a rational number is equal to another and returns the result.
Explicit(BigRational to BigInteger) Converts a BigRational to a BigInteger number.
Explicit(BigRational to Byte) Converts a BigRational to a Byte value.
Explicit(BigRational to Decimal) Converts a BigRational to a Decimal number.
Explicit(BigRational to Double) Converts a BigRational to a double-precision floating-point number.
Explicit(BigRational to Int16) Converts a BigRational to a Int16 value.
Explicit(BigRational to Int32) Converts a BigRational to a Int32 value.
Explicit(BigRational to Int64) Converts a BigRational to a long integer.
Explicit(BigRational to SByte) Converts a BigRational to a SByte value.
Explicit(BigRational to Single) Converts a BigRational to a single-precision floating-point number.
Explicit(BigRational to UInt16) Converts a BigRational to a UInt16 value.
Explicit(BigRational to UInt32) Converts a BigRational to an unsigned integer.
Explicit(BigRational to UInt64) Converts a BigRational to a long unsigned integer.
Explicit(Decimal to BigRational) Converts a Decimal number to a BigInteger value.
Explicit(Double to BigRational) Converts a double-precision floating-point number to a BigInteger value.
Explicit(Single to BigRational) Converts a single-precision floating-point number to a BigInteger value.
Exponent(BigRational, Int32) Represents the exponentiation operator.
Exponentiation(BigRational, Int32) Represents the exponentiation operator.
GreaterThan(BigRational, BigInteger) Determines if a rational number is greater than another and returns the result.
GreaterThan(BigRational, BigRational) Determines if a rational number is greater than another and returns the result.
GreaterThan(BigRational, Int32) Determines if a rational number is greater than another and returns the result.
GreaterThanOrEqual(BigRational, BigInteger) Determines if a rational number is greater than or equal to another and returns the result.
GreaterThanOrEqual(BigRational, BigRational) Determines if a rational number is greater than or equal to another and returns the result.
GreaterThanOrEqual(BigRational, Int32) Determines if a rational number is greater than or equal to another and returns the result.
Implicit(BigInteger to BigRational) Converts a BigInteger value to a BigRational value.
Implicit(Byte to BigRational) Converts a Byte value to a BigRational value.
Implicit(Int128 to BigRational) Converts a 128 bit signed integer to a BigRational value.
Implicit(Int16 to BigRational) Converts a 16 bit signed integer to a BigRational value.
Implicit(Int32 to BigRational) Converts a 32 bit signed integer to a BigRational value.
Implicit(Int64 to BigRational) Converts a 64 bit signed integer to a BigRational value.
Implicit(SByte to BigRational) Converts a SByte value to a BigRational value.
Implicit(UInt128 to BigRational) Converts a 128 bit unsigned integer to a BigRational value.
Implicit(UInt16 to BigRational) Converts a 16 bit unsigned integer to a BigRational value.
Implicit(UInt32 to BigRational) Converts a 32 bit unsigned integer to a BigRational value.
Implicit(UInt64 to BigRational) Converts a 64 bit unsigned integer to a BigRational value.
Increment(BigRational)Increments a value.
Inequality(BigRational, BigInteger) Determines if a rational number is not equal to another and returns the result.
Inequality(BigRational, BigRational) Determines if a rational number is not equal to another and returns the result.
Inequality(BigRational, Int32) Determines if a rational number is not equal to another and returns the result.
LessThan(BigRational, BigInteger) Determines if a rational number is less than another and returns the result.
LessThan(BigRational, BigRational) Determines if a rational number is less than another and returns the result.
LessThan(BigRational, Int32) Determines if a rational number is less than another and returns the result.
LessThanOrEqual(BigRational, BigInteger) Determines if a rational number is less than or equal to another and returns the result.
LessThanOrEqual(BigRational, BigRational) Determines if a rational number is less than or equal to another and returns the result.
LessThanOrEqual(BigRational, Int32) Determines if a rational number is less than or equal to another and returns the result.
Modulus(BigRational, BigRational) Returns the remainder after dividing one BigRational by another and returns the result.
Multiply(BigInteger, BigRational) Multiplies a rational number by an arbitrary precision integer.
Multiply(BigRational, BigInteger) Multiplies a rational number by an arbitrary precision integer.
Multiply(BigRational, BigRational) Multiplies two rational numbers.
Multiply(BigRational, Int32) Multiplies a rational number by an integer.
Multiply(Int32, BigRational) Multiplies a rational number by an integer.
Subtraction(BigInteger, BigRational) Subtracts a rational number from a big integer.
Subtraction(BigRational, BigInteger) Subtracts a big integer from a rational number.
Subtraction(BigRational, BigRational) Subtracts a rational number from another and returns the result.
Subtraction(BigRational, Int32) Subtracts an integer from a rational number.
Subtraction(Int32, BigRational) Subtracts a rational number from an integer.
UnaryNegation(BigRational) Negates a rational number from another and returns the result.
UnaryPlus(BigRational)Computes the unary plus of a value.

Fields

MaxValue The largest possible rational number.
MinusOne The number 1 as a rational number.
MinValue The smallest possible rational number.
One The number 1 as a rational number.
Zero The number 0 as a rational number.

See Also