# 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)

The Rational type exposes the following members.

Name | Description | |
---|---|---|

AbsoluteValue | Gets the absolute value of a number. | |

BitCount | Gets an integer that represents the number of bits. | |

Denominator | Gets the denominator of a number. | |

HasSign | Returns a value that indicates whether a Rational object is signed. | |

IsFinite | Returns a value that indicates whether a Rational object is finite. | |

IsIndeterminate | Returns a value that indicates whether a Rational object is indeterminate. | |

IsInfinite | Returns a value that indicates whether a Rational object is infinite. | |

IsNegativeInfinity | Returns a value that indicates whether a Rational object is negative infinity. | |

IsOne | Returns a value that indicates whether a Rational object is equal to one. | |

IsPositiveInfinity | Returns a value that indicates whether a Rational object is positive infinity. | |

IsSignedInfinity | Returns a value that indicates whether a Rational object is signed infinity. | |

IsUnsignedInfinity | Returns a value that indicates whether a Rational object is unsigned infinity. | |

IsZero | Returns a value that indicates whether a Rational object is equal to zero. | |

Numerator | Gets the numerator of a number. | |

Sign | Gets a value that indicates the sign of a number. |

Name | Description | |
---|---|---|

AddMul | Performs and optimizes the operation ratAdd + ratMul1 * ratMul2. | |

AppendDecimalString | Appends 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. | |

Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |

Get | Creates a rational number by dividing one big integer by another. | |

GetCeiling | Returns the ceiling of a rational number. | |

GetCeilingResidual | Returns the ceiling residual of a rational number. | |

GetFloor | Returns the floor of a rational number. | |

GetFloorResidual | Returns the floor residual of a rational number. | |

GetFractionalPart | Returns the fractional part of a rational number. | |

GetHashCode | Returns the hash code of a rational number. (Overrides ValueType.GetHashCode.) | |

GetIntegerPart | Returns the integer part of a rational number. | |

GetSignedDouble | Converts a rational number to a signed double. | |

GetType | Gets the Type of the current instance. (Inherited from Object.) | |

Invert | Inverts the sign of a rational number. | |

IsInteger | Returns 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. | |

MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |

Negate | Negates the sign of a rational number. | |

Power | Returns a value that indicates whether a rational number was raised to the power of another rational number successfully. | |

ToDouble | Converts a rational number to the nearest double. | |

ToString | Converts a rational number to its equivalent string representation. (Overrides ValueType.ToString.) |

Name | Description | |
---|---|---|

Addition | Adds two rational numbers. | |

Division | Divides 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. | |

Multiply | Returns the product of two rational numbers. | |

Subtraction | Subtracts a rational number from another rational number. | |

UnaryNegation | Negates a specified rational number. |

Name | Description | |
---|---|---|

Indeterminate | Represents a Rational object that is not a number. | |

NegativeInfinity | Represents a Rational object that is equal to negative infinity (-1, 0). | |

One | Represents a Rational object that is equal to 1. | |

PositiveInfinity | Represents a Rational object that is equal to positive infinity (+1, 0). | |

UnsignedInfinity | Represents a Rational object that is equal to unsigned infinity (+2, 0). | |

Zero | Represents a Rational object that is equal to 0. |

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.

Show: