# Rational Structure

Solver Foundation 3.0

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents a rational number.

Namespace:  Microsoft.SolverFoundation.Common
Assembly:  Microsoft.Solver.Foundation (in Microsoft.Solver.Foundation.dll)

## Syntax

```'Declaration
<CLSCompliantAttribute(True)> _
Public Structure Rational _
Implements IComparable, IComparable(Of Rational),  _
IEquatable(Of Rational), IComparable(Of BigInteger), IEquatable(Of BigInteger),  _
IComparable(Of Integer), IEquatable(Of Integer), IComparable(Of UInteger),  _
IEquatable(Of UInteger), IComparable(Of Long), IEquatable(Of Long),  _
IComparable(Of ULong), IEquatable(Of ULong), IComparable(Of Double),  _
IEquatable(Of Double)
```

The Rational type exposes the following members.

## Properties

NameDescription
AbsoluteValueGets the absolute value of a number.
BitCountGets an integer that represents the number of bits.
DenominatorGets the denominator of a number.
HasSignReturns a value that indicates whether a Rational object is signed.
IsFiniteReturns a value that indicates whether a Rational object is finite.
IsIndeterminateReturns a value that indicates whether a Rational object is indeterminate.
IsInfiniteReturns a value that indicates whether a Rational object is infinite.
IsNegativeInfinityReturns a value that indicates whether a Rational object is negative infinity.
IsOneReturns a value that indicates whether a Rational object is equal to one.
IsPositiveInfinityReturns a value that indicates whether a Rational object is positive infinity.
IsSignedInfinityReturns a value that indicates whether a Rational object is signed infinity.
IsUnsignedInfinityReturns a value that indicates whether a Rational object is unsigned infinity.
IsZeroReturns a value that indicates whether a Rational object is equal to zero.
NumeratorGets the numerator of a number.
SignGets a value that indicates the sign of a number.
Top

## Methods

NameDescription
AppendDecimalStringAppends characters to a string.
CompareTo(Double)Compares a rational number to a double.
CompareTo(Int32)Compares a rational number to an integer.
CompareTo(Int64)Compares a rational number to a long integer.
CompareTo(Object)Compares a rational number to another number (Int32, UInt32, Double, Int64, UInt64, Rational, or BigInteger).
CompareTo(UInt32)Compares a rational number to an unsigned integer.
CompareTo(UInt64)Compares a rational number to an unsigned long integer.
CompareTo(BigInteger)Compares a rational number to a big integer.
CompareTo(Rational)Compares a rational number to another rational number.
Equals(Double)Returns a value that indicates whether a rational number is equal to a double.
Equals(Int32)Returns a value that indicates whether a rational number is equal to an integer.
Equals(Int64)Returns a value that indicates whether a rational number is equal to a long integer.
Equals(Object)Returns a value that indicates whether a rational number is equal to another number (Int32, UInt32, Double, Int64, UInt64, Rational, or BigInteger). (Overrides ValueType.Equals(Object).)
Equals(UInt32)Returns a value that indicates whether a rational number is equal to an unsigned integer.
Equals(UInt64)Returns a value that indicates whether a rational number is equal to an unsigned long integer.
Equals(BigInteger)Returns a value that indicates whether a rational number is equal to a big integer.
Equals(Rational)Returns a value that indicates whether a rational number is equal to another rational number.
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
GetCreates a rational number by dividing one big integer by another.
GetCeilingReturns the ceiling of a rational number.
GetCeilingResidualReturns the ceiling residual of a rational number.
GetFloorReturns the floor of a rational number.
GetFloorResidualReturns the floor residual of a rational number.
GetFractionalPartReturns the fractional part of a rational number.
GetHashCodeReturns the hash code of a rational number. (Overrides ValueType.GetHashCode.)
GetIntegerPartReturns the integer part of a rational number.
GetSignedDoubleConverts a rational number to a signed double.
GetTypeGets the Type of the current instance. (Inherited from Object.)
InvertInverts the sign of a rational number.
IsIntegerReturns a value that indicates whether a number is an integer.
IsInteger(BigInteger)Returns a value that indicates whether a number is an integer, and clones the integer.
MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
NegateNegates the sign of a rational number.
PowerReturns a value that indicates whether a rational number was raised to the power of another rational number successfully.
ToDoubleConverts a rational number to the nearest double.
ToStringConverts a rational number to its equivalent string representation. (Overrides ValueType.ToString.)
Top

## Operators

NameDescription
DivisionDivides one rational number by another.
Equality(Double, Rational)Returns a value that indicates whether a double is equal to a rational number.
Equality(Int32, Rational)Returns a value that indicates whether an integer is equal to a rational number.
Equality(Int64, Rational)Returns a value that indicates whether a long integer is equal to a rational number.
Equality(UInt32, Rational)Returns a value that indicates whether an unsigned integer is equal to a rational number.
Equality(UInt64, Rational)Returns a value that indicates whether an unsigned long is equal to a rational number.
Equality(BigInteger, Rational)Returns a value that indicates whether a big integer is equal to a rational number.
Equality(Rational, BigInteger)Returns a value that indicates whether a rational number is equal to a big integer.
Equality(Rational, Rational)Returns a value that indicates whether a rational number is equal to another rational number.
Equality(Rational, Double)Returns a value that indicates whether a rational number is equal to a double.
Equality(Rational, Int32)Returns a value that indicates whether a rational number is equal to an integer.
Equality(Rational, Int64)Returns a value that indicates whether a rational number is equal to a long integer.
Equality(Rational, UInt32)Returns a value that indicates whether a rational number is equal to an unsigned integer.
Equality(Rational, UInt64)Returns a value that indicates whether a rational number is equal to an unsigned long integer.
Narrowing(Rational to UInt32)Converts a rational number to an unsigned integer.
Narrowing(Rational to Int32)Converts a rational number to an integer.
Narrowing(Rational to Double)Converts a rational number to a double.
Narrowing(Rational to BigInteger)Converts a rational number to a big integer.
Narrowing(Rational to Int64)Converts a rational number to a long integer.
Narrowing(Rational to UInt64)Converts a rational number to an unsigned long integer.
GreaterThan(Double, Rational)Returns a value that indicates whether a double is greater than a rational number.
GreaterThan(Int32, Rational)Returns a value that indicates whether an integer is greater than a rational number.
GreaterThan(Int64, Rational)Returns a value that indicates whether a long integer is greater than a rational number.
GreaterThan(UInt32, Rational)Returns a value that indicates whether an unsigned integer is greater than rational number.
GreaterThan(UInt64, Rational)Returns a value that indicates whether an unsigned long integer is greater than rational number.
GreaterThan(BigInteger, Rational)Returns a value that indicates whether a big integer is greater than a rational number.
GreaterThan(Rational, BigInteger)Returns a value that indicates whether a rational number is greater than a big integer.
GreaterThan(Rational, Rational)Returns a value that indicates whether one rational number is greater than another rational number.
GreaterThan(Rational, Double)Returns a value that indicates whether a rational number is greater than a double.
GreaterThan(Rational, Int32)Returns a value that indicates whether a rational number is greater than an integer.
GreaterThan(Rational, Int64)Returns a value that indicates whether a rational number is greater than a long integer.
GreaterThan(Rational, UInt32)Returns a value that indicates whether a rational number is greater than an unsigned integer.
GreaterThan(Rational, UInt64)Returns a value that indicates whether a rational number is greater than an unsigned long integer.
GreaterThanOrEqual(Double, Rational)Returns a value that indicates whether a double is greater than or equal to a rational number.
GreaterThanOrEqual(Int32, Rational)Returns a value that indicates whether an integer is greater than or equal to a rational number.
GreaterThanOrEqual(Int64, Rational)Returns a value that indicates whether a long integer is greater than or equal to a rational number.
GreaterThanOrEqual(UInt32, Rational)Returns a value that indicates whether an unsigned integer is greater than or equal to a rational number.
GreaterThanOrEqual(UInt64, Rational)Returns a value that indicates whether an unsigned long integer is greater than or equal to a rational number.
GreaterThanOrEqual(BigInteger, Rational)Returns a value that indicates whether a big integer is greater than or equal to a rational number.
GreaterThanOrEqual(Rational, BigInteger)Returns a value that indicates whether a rational number is greater than or equal to a big integer.
GreaterThanOrEqual(Rational, Rational)Returns a value that indicates whether a rational number is greater than or equal to another rational number.
GreaterThanOrEqual(Rational, Double)Returns a value that indicates whether a rational number is greater than or equal to a double.
GreaterThanOrEqual(Rational, Int32)Returns a value that indicates whether a rational number is greater than or equal to an integer.
GreaterThanOrEqual(Rational, Int64)Returns a value that indicates whether a rational number is greater than or equal to a long integer.
GreaterThanOrEqual(Rational, UInt32)Returns a value that indicates whether a rational number is greater than or equal to an unsigned integer.
GreaterThanOrEqual(Rational, UInt64)Returns a value that indicates whether a rational number is greater than or equal to an unsigned long integer.
Widening(Double to Rational)Converts a double to a rational number.
Widening(Int32 to Rational)Converts an integer to a rational number.
Widening(Int64 to Rational)Converts a long integer to a rational number.
Widening(UInt32 to Rational)Converts an unsigned integer to a rational number.
Widening(UInt64 to Rational)Converts an unsigned long integer to a rational number.
Widening(BigInteger to Rational)Converts a big integer to a rational number.
Inequality(Double, Rational)Returns a value that indicates whether a double is not equal to a rational number.
Inequality(Int32, Rational)Returns a value that indicates whether an integer is not equal to a rational number.
Inequality(Int64, Rational)Returns a value that indicates whether a long integer is not equal to a rational number.
Inequality(UInt32, Rational)Returns a value that indicates whether an unsigned integer is not equal to a rational number.
Inequality(UInt64, Rational)Returns a value that indicates whether an unsigned long integer is not equal to a rational number.
Inequality(BigInteger, Rational)Returns a value that indicates whether a big integer is not equal to a rational number.
Inequality(Rational, BigInteger)Returns a value that indicates whether a rational number is not equal to a big integer.
Inequality(Rational, Rational)Returns a value that indicates whether a rational number is not equal to a rational number.
Inequality(Rational, Double)Returns a value that indicates whether a rational number is not equal to a double.
Inequality(Rational, Int32)Returns a value that indicates whether a rational number is not equal to an integer.
Inequality(Rational, Int64)Returns a value that indicates whether a rational number is not equal to a long.
Inequality(Rational, UInt32)Returns a value that indicates whether a rational number is not equal to an unsigned integer.
Inequality(Rational, UInt64)Returns a value that indicates whether a rational number is not equal to an unsigned long integer.
LessThan(Double, Rational)Returns a value that indicates whether a double is less than a rational number.
LessThan(Int32, Rational)Returns a value that indicates whether an integer is less than a rational number.
LessThan(Int64, Rational)Returns a value that indicates whether a long integer is less than a rational number.
LessThan(UInt32, Rational)Returns a value that indicates whether an unsigned integer is less than a rational number.
LessThan(UInt64, Rational)Returns a value that indicates whether an unsigned long integer is less than a rational number.
LessThan(BigInteger, Rational)Returns a value that indicates whether a big integer is less than a rational number.
LessThan(Rational, BigInteger)Returns a value that indicates whether a rational number is less than a big integer.
LessThan(Rational, Rational)Returns a value that indicates whether a rational number is less than another rational number.
LessThan(Rational, Double)Returns a value that indicates whether a rational number is less than a double.
LessThan(Rational, Int32)Returns a value that indicates whether a rational number is less than an integer.
LessThan(Rational, Int64)Returns a value that indicates whether a rational number is less than a long integer.
LessThan(Rational, UInt32)Returns a value that indicates whether a rational number is less than an unsigned integer.
LessThan(Rational, UInt64)Returns a value that indicates whether a rational number is less than an unsigned long integer.
LessThanOrEqual(Double, Rational)Returns a value that indicates whether a double is less than or equal to a rational number.
LessThanOrEqual(Int32, Rational)Returns a value that indicates whether an integer is less than or equal to a rational number.
LessThanOrEqual(Int64, Rational)Returns a value that indicates whether a long integer is less than or equal to a rational number.
LessThanOrEqual(UInt32, Rational)Returns a value that indicates whether an unsigned integer is less than or equal to a rational number.
LessThanOrEqual(UInt64, Rational)Returns a value that indicates whether an unsigned long integer is less than or equal to a rational number.
LessThanOrEqual(BigInteger, Rational)Returns a value that indicates whether a big integer is less than or equal to a rational number.
LessThanOrEqual(Rational, BigInteger)Returns a value that indicates whether a rational number is less than or equal to a big integer.
LessThanOrEqual(Rational, Rational)Returns a value that indicates whether a rational number is less than or equal to another rational number.
LessThanOrEqual(Rational, Double)Returns a value that indicates whether a rational number is less than or equal to a double.
LessThanOrEqual(Rational, Int32)Returns a value that indicates whether a rational number is less than or equal to an integer.
LessThanOrEqual(Rational, Int64)Returns a value that indicates whether a rational number is less than or equal to a long integer.
LessThanOrEqual(Rational, UInt32)Returns a value that indicates whether a rational number is less than or equal to an unsigned integer.
LessThanOrEqual(Rational, UInt64)Returns a value that indicates whether a rational number is less than or equal to an unsigned long integer.
MultiplyReturns the product of two rational numbers.
SubtractionSubtracts a rational number from another rational number.
UnaryNegationNegates a specified rational number.
Top

## Fields

NameDescription
IndeterminateRepresents a Rational object that is not a number.
NegativeInfinityRepresents a Rational object that is equal to negative infinity (-1, 0).
OneRepresents a Rational object that is equal to 1.
PositiveInfinityRepresents a Rational object that is equal to positive infinity (+1, 0).
UnsignedInfinityRepresents a Rational object that is equal to unsigned infinity (+2, 0).
ZeroRepresents a Rational object that is equal to 0.
Top

## Remarks

The following table lists how special cases of rational numbers are represented.

Rational number

Representation

Non-zero finite rational values

(numerator, denominator) with denominator > 0

Zero

(0, 0)

Negative infinity

(-1, 0)

Positive infinity

(+1, 0)

Unsigned infinity

(+2, 0)

Indeterminate (NaN)

(+3, 0)

Dividing a nonzero value by zero results in unsigned infinity because 0 is unsigned. Dividing a finite value by any infinite value results in 0.