Rational Structure
[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)
[CLSCompliantAttribute(true)]
public struct Rational : IComparable, IComparable<Rational>,
IEquatable<Rational>, IComparable<BigInteger>, IEquatable<BigInteger>,
IComparable<int>, IEquatable<int>, IComparable<uint>, IEquatable<uint>,
IComparable<long>, IEquatable<long>, IComparable<ulong>, IEquatable<ulong>,
IComparable<double>, IEquatable<double>
[CLSCompliantAttribute(true)]
public value class Rational : IComparable,
IComparable<Rational>, IEquatable<Rational>, IComparable<BigInteger>,
IEquatable<BigInteger>, IComparable<int>, IEquatable<int>, IComparable<unsigned int>,
IEquatable<unsigned int>, IComparable<long long>, IEquatable<long long>,
IComparable<unsigned long long>, IEquatable<unsigned long long>,
IComparable<double>, IEquatable<double>
[<Sealed>]
[<CLSCompliantAttribute(true)>]
type Rational =
struct
interface IComparable
interface IComparable<Rational>
interface IEquatable<Rational>
interface IComparable<BigInteger>
interface IEquatable<BigInteger>
interface IComparable<int>
interface IEquatable<int>
interface IComparable<uint32>
interface IEquatable<uint32>
interface IComparable<int64>
interface IEquatable<int64>
interface IComparable<uint64>
interface IEquatable<uint64>
interface IComparable<float>
interface IEquatable<float>
end
JScript supports the use of structures, but not the declaration of new ones.
The Rational type exposes the following members.
Properties
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. |
Top
Methods
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().) |
Top
Operators
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. | |
Explicit(Rational to UInt32) | Converts a rational number to an unsigned integer. | |
Explicit(Rational to Int32) | Converts a rational number to an integer. | |
Explicit(Rational to Double) | Converts a rational number to a double. | |
Explicit(Rational to BigInteger) | Converts a rational number to a big integer. | |
Explicit(Rational to Int64) | Converts a rational number to a long integer. | |
Explicit(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. | |
Implicit(Double to Rational) | Converts a double to a rational number. | |
Implicit(Int32 to Rational) | Converts an integer to a rational number. | |
Implicit(Int64 to Rational) | Converts a long integer to a rational number. | |
Implicit(UInt32 to Rational) | Converts an unsigned integer to a rational number. | |
Implicit(UInt64 to Rational) | Converts an unsigned long integer to a rational number. | |
Implicit(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. |
Top
Fields
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. |
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.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.