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
Public property AbsoluteValue Gets the absolute value of a number.
Public property BitCount Gets an integer that represents the number of bits.
Public property Denominator Gets the denominator of a number.
Public property HasSign Returns a value that indicates whether a Rational object is signed.
Public property IsFinite Returns a value that indicates whether a Rational object is finite.
Public property IsIndeterminate Returns a value that indicates whether a Rational object is indeterminate.
Public property IsInfinite Returns a value that indicates whether a Rational object is infinite.
Public property IsNegativeInfinity Returns a value that indicates whether a Rational object is negative infinity.
Public property IsOne Returns a value that indicates whether a Rational object is equal to one.
Public property IsPositiveInfinity Returns a value that indicates whether a Rational object is positive infinity.
Public property IsSignedInfinity Returns a value that indicates whether a Rational object is signed infinity.
Public property IsUnsignedInfinity Returns a value that indicates whether a Rational object is unsigned infinity.
Public property IsZero Returns a value that indicates whether a Rational object is equal to zero.
Public property Numerator Gets the numerator of a number.
Public property Sign Gets a value that indicates the sign of a number.

Top

Methods

  Name Description
Public methodStatic member AddMul Performs and optimizes the operation ratAdd + ratMul1 * ratMul2.
Public method AppendDecimalString Appends characters to a string.
Public method CompareTo(Double) Compares a rational number to a double.
Public method CompareTo(Int32) Compares a rational number to an integer.
Public method CompareTo(Int64) Compares a rational number to a long integer.
Public method CompareTo(Object) Compares a rational number to another number (Int32, UInt32, Double, Int64, UInt64, Rational, or BigInteger).
Public method CompareTo(UInt32) Compares a rational number to an unsigned integer.
Public method CompareTo(UInt64) Compares a rational number to an unsigned long integer.
Public method CompareTo(BigInteger) Compares a rational number to a big integer.
Public method CompareTo(Rational) Compares a rational number to another rational number.
Public method Equals(Double) Returns a value that indicates whether a rational number is equal to a double.
Public method Equals(Int32) Returns a value that indicates whether a rational number is equal to an integer.
Public method Equals(Int64) Returns a value that indicates whether a rational number is equal to a long integer.
Public method 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).)
Public method Equals(UInt32) Returns a value that indicates whether a rational number is equal to an unsigned integer.
Public method Equals(UInt64) Returns a value that indicates whether a rational number is equal to an unsigned long integer.
Public method Equals(BigInteger) Returns a value that indicates whether a rational number is equal to a big integer.
Public method Equals(Rational) Returns a value that indicates whether a rational number is equal to another rational number.
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic member Get Creates a rational number by dividing one big integer by another.
Public method GetCeiling Returns the ceiling of a rational number.
Public method GetCeilingResidual Returns the ceiling residual of a rational number.
Public method GetFloor Returns the floor of a rational number.
Public method GetFloorResidual Returns the floor residual of a rational number.
Public method GetFractionalPart Returns the fractional part of a rational number.
Public method GetHashCode Returns the hash code of a rational number. (Overrides ValueType.GetHashCode().)
Public method GetIntegerPart Returns the integer part of a rational number.
Public method GetSignedDouble Converts a rational number to a signed double.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Invert Inverts the sign of a rational number.
Public method IsInteger() Returns a value that indicates whether a number is an integer.
Public method IsInteger(BigInteger%) Returns a value that indicates whether a number is an integer, and clones the integer.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic member Negate Negates the sign of a rational number.
Public methodStatic member Power Returns a value that indicates whether a rational number was raised to the power of another rational number successfully.
Public method ToDouble Converts a rational number to the nearest double.
Public method ToString Converts a rational number to its equivalent string representation. (Overrides ValueType.ToString().)

Top

Operators

  Name Description
Public operatorStatic member Addition Adds two rational numbers.
Public operatorStatic member Division Divides one rational number by another.
Public operatorStatic member Equality(Double, Rational) Returns a value that indicates whether a double is equal to a rational number.
Public operatorStatic member Equality(Int32, Rational) Returns a value that indicates whether an integer is equal to a rational number.
Public operatorStatic member Equality(Int64, Rational) Returns a value that indicates whether a long integer is equal to a rational number.
Public operatorStatic member Equality(UInt32, Rational) Returns a value that indicates whether an unsigned integer is equal to a rational number.
Public operatorStatic member Equality(UInt64, Rational) Returns a value that indicates whether an unsigned long is equal to a rational number.
Public operatorStatic member Equality(BigInteger, Rational) Returns a value that indicates whether a big integer is equal to a rational number.
Public operatorStatic member Equality(Rational, BigInteger) Returns a value that indicates whether a rational number is equal to a big integer.
Public operatorStatic member Equality(Rational, Rational) Returns a value that indicates whether a rational number is equal to another rational number.
Public operatorStatic member Equality(Rational, Double) Returns a value that indicates whether a rational number is equal to a double.
Public operatorStatic member Equality(Rational, Int32) Returns a value that indicates whether a rational number is equal to an integer.
Public operatorStatic member Equality(Rational, Int64) Returns a value that indicates whether a rational number is equal to a long integer.
Public operatorStatic member Equality(Rational, UInt32) Returns a value that indicates whether a rational number is equal to an unsigned integer.
Public operatorStatic member Equality(Rational, UInt64) Returns a value that indicates whether a rational number is equal to an unsigned long integer.
Public operatorStatic member Explicit(Rational to UInt32) Converts a rational number to an unsigned integer.
Public operatorStatic member Explicit(Rational to Int32) Converts a rational number to an integer.
Public operatorStatic member Explicit(Rational to Double) Converts a rational number to a double.
Public operatorStatic member Explicit(Rational to BigInteger) Converts a rational number to a big integer.
Public operatorStatic member Explicit(Rational to Int64) Converts a rational number to a long integer.
Public operatorStatic member Explicit(Rational to UInt64) Converts a rational number to an unsigned long integer.
Public operatorStatic member GreaterThan(Double, Rational) Returns a value that indicates whether a double is greater than a rational number.
Public operatorStatic member GreaterThan(Int32, Rational) Returns a value that indicates whether an integer is greater than a rational number.
Public operatorStatic member GreaterThan(Int64, Rational) Returns a value that indicates whether a long integer is greater than a rational number.
Public operatorStatic member GreaterThan(UInt32, Rational) Returns a value that indicates whether an unsigned integer is greater than rational number.
Public operatorStatic member GreaterThan(UInt64, Rational) Returns a value that indicates whether an unsigned long integer is greater than rational number.
Public operatorStatic member GreaterThan(BigInteger, Rational) Returns a value that indicates whether a big integer is greater than a rational number.
Public operatorStatic member GreaterThan(Rational, BigInteger) Returns a value that indicates whether a rational number is greater than a big integer.
Public operatorStatic member GreaterThan(Rational, Rational) Returns a value that indicates whether one rational number is greater than another rational number.
Public operatorStatic member GreaterThan(Rational, Double) Returns a value that indicates whether a rational number is greater than a double.
Public operatorStatic member GreaterThan(Rational, Int32) Returns a value that indicates whether a rational number is greater than an integer.
Public operatorStatic member GreaterThan(Rational, Int64) Returns a value that indicates whether a rational number is greater than a long integer.
Public operatorStatic member GreaterThan(Rational, UInt32) Returns a value that indicates whether a rational number is greater than an unsigned integer.
Public operatorStatic member GreaterThan(Rational, UInt64) Returns a value that indicates whether a rational number is greater than an unsigned long integer.
Public operatorStatic member GreaterThanOrEqual(Double, Rational) Returns a value that indicates whether a double is greater than or equal to a rational number.
Public operatorStatic member GreaterThanOrEqual(Int32, Rational) Returns a value that indicates whether an integer is greater than or equal to a rational number.
Public operatorStatic member GreaterThanOrEqual(Int64, Rational) Returns a value that indicates whether a long integer is greater than or equal to a rational number.
Public operatorStatic member GreaterThanOrEqual(UInt32, Rational) Returns a value that indicates whether an unsigned integer is greater than or equal to a rational number.
Public operatorStatic member GreaterThanOrEqual(UInt64, Rational) Returns a value that indicates whether an unsigned long integer is greater than or equal to a rational number.
Public operatorStatic member GreaterThanOrEqual(BigInteger, Rational) Returns a value that indicates whether a big integer is greater than or equal to a rational number.
Public operatorStatic member GreaterThanOrEqual(Rational, BigInteger) Returns a value that indicates whether a rational number is greater than or equal to a big integer.
Public operatorStatic member GreaterThanOrEqual(Rational, Rational) Returns a value that indicates whether a rational number is greater than or equal to another rational number.
Public operatorStatic member GreaterThanOrEqual(Rational, Double) Returns a value that indicates whether a rational number is greater than or equal to a double.
Public operatorStatic member GreaterThanOrEqual(Rational, Int32) Returns a value that indicates whether a rational number is greater than or equal to an integer.
Public operatorStatic member GreaterThanOrEqual(Rational, Int64) Returns a value that indicates whether a rational number is greater than or equal to a long integer.
Public operatorStatic member GreaterThanOrEqual(Rational, UInt32) Returns a value that indicates whether a rational number is greater than or equal to an unsigned integer.
Public operatorStatic member GreaterThanOrEqual(Rational, UInt64) Returns a value that indicates whether a rational number is greater than or equal to an unsigned long integer.
Public operatorStatic member Implicit(Double to Rational) Converts a double to a rational number.
Public operatorStatic member Implicit(Int32 to Rational) Converts an integer to a rational number.
Public operatorStatic member Implicit(Int64 to Rational) Converts a long integer to a rational number.
Public operatorStatic member Implicit(UInt32 to Rational) Converts an unsigned integer to a rational number.
Public operatorStatic member Implicit(UInt64 to Rational) Converts an unsigned long integer to a rational number.
Public operatorStatic member Implicit(BigInteger to Rational) Converts a big integer to a rational number.
Public operatorStatic member Inequality(Double, Rational) Returns a value that indicates whether a double is not equal to a rational number.
Public operatorStatic member Inequality(Int32, Rational) Returns a value that indicates whether an integer is not equal to a rational number.
Public operatorStatic member Inequality(Int64, Rational) Returns a value that indicates whether a long integer is not equal to a rational number.
Public operatorStatic member Inequality(UInt32, Rational) Returns a value that indicates whether an unsigned integer is not equal to a rational number.
Public operatorStatic member Inequality(UInt64, Rational) Returns a value that indicates whether an unsigned long integer is not equal to a rational number.
Public operatorStatic member Inequality(BigInteger, Rational) Returns a value that indicates whether a big integer is not equal to a rational number.
Public operatorStatic member Inequality(Rational, BigInteger) Returns a value that indicates whether a rational number is not equal to a big integer.
Public operatorStatic member Inequality(Rational, Rational) Returns a value that indicates whether a rational number is not equal to a rational number.
Public operatorStatic member Inequality(Rational, Double) Returns a value that indicates whether a rational number is not equal to a double.
Public operatorStatic member Inequality(Rational, Int32) Returns a value that indicates whether a rational number is not equal to an integer.
Public operatorStatic member Inequality(Rational, Int64) Returns a value that indicates whether a rational number is not equal to a long.
Public operatorStatic member Inequality(Rational, UInt32) Returns a value that indicates whether a rational number is not equal to an unsigned integer.
Public operatorStatic member Inequality(Rational, UInt64) Returns a value that indicates whether a rational number is not equal to an unsigned long integer.
Public operatorStatic member LessThan(Double, Rational) Returns a value that indicates whether a double is less than a rational number.
Public operatorStatic member LessThan(Int32, Rational) Returns a value that indicates whether an integer is less than a rational number.
Public operatorStatic member LessThan(Int64, Rational) Returns a value that indicates whether a long integer is less than a rational number.
Public operatorStatic member LessThan(UInt32, Rational) Returns a value that indicates whether an unsigned integer is less than a rational number.
Public operatorStatic member LessThan(UInt64, Rational) Returns a value that indicates whether an unsigned long integer is less than a rational number.
Public operatorStatic member LessThan(BigInteger, Rational) Returns a value that indicates whether a big integer is less than a rational number.
Public operatorStatic member LessThan(Rational, BigInteger) Returns a value that indicates whether a rational number is less than a big integer.
Public operatorStatic member LessThan(Rational, Rational) Returns a value that indicates whether a rational number is less than another rational number.
Public operatorStatic member LessThan(Rational, Double) Returns a value that indicates whether a rational number is less than a double.
Public operatorStatic member LessThan(Rational, Int32) Returns a value that indicates whether a rational number is less than an integer.
Public operatorStatic member LessThan(Rational, Int64) Returns a value that indicates whether a rational number is less than a long integer.
Public operatorStatic member LessThan(Rational, UInt32) Returns a value that indicates whether a rational number is less than an unsigned integer.
Public operatorStatic member LessThan(Rational, UInt64) Returns a value that indicates whether a rational number is less than an unsigned long integer.
Public operatorStatic member LessThanOrEqual(Double, Rational) Returns a value that indicates whether a double is less than or equal to a rational number.
Public operatorStatic member LessThanOrEqual(Int32, Rational) Returns a value that indicates whether an integer is less than or equal to a rational number.
Public operatorStatic member LessThanOrEqual(Int64, Rational) Returns a value that indicates whether a long integer is less than or equal to a rational number.
Public operatorStatic member LessThanOrEqual(UInt32, Rational) Returns a value that indicates whether an unsigned integer is less than or equal to a rational number.
Public operatorStatic member LessThanOrEqual(UInt64, Rational) Returns a value that indicates whether an unsigned long integer is less than or equal to a rational number.
Public operatorStatic member LessThanOrEqual(BigInteger, Rational) Returns a value that indicates whether a big integer is less than or equal to a rational number.
Public operatorStatic member LessThanOrEqual(Rational, BigInteger) Returns a value that indicates whether a rational number is less than or equal to a big integer.
Public operatorStatic member LessThanOrEqual(Rational, Rational) Returns a value that indicates whether a rational number is less than or equal to another rational number.
Public operatorStatic member LessThanOrEqual(Rational, Double) Returns a value that indicates whether a rational number is less than or equal to a double.
Public operatorStatic member LessThanOrEqual(Rational, Int32) Returns a value that indicates whether a rational number is less than or equal to an integer.
Public operatorStatic member LessThanOrEqual(Rational, Int64) Returns a value that indicates whether a rational number is less than or equal to a long integer.
Public operatorStatic member LessThanOrEqual(Rational, UInt32) Returns a value that indicates whether a rational number is less than or equal to an unsigned integer.
Public operatorStatic member LessThanOrEqual(Rational, UInt64) Returns a value that indicates whether a rational number is less than or equal to an unsigned long integer.
Public operatorStatic member Multiply Returns the product of two rational numbers.
Public operatorStatic member Subtraction Subtracts a rational number from another rational number.
Public operatorStatic member UnaryNegation Negates a specified rational number.

Top

Fields

  Name Description
Public fieldStatic member Indeterminate Represents a Rational object that is not a number.
Public fieldStatic member NegativeInfinity Represents a Rational object that is equal to negative infinity (-1, 0).
Public fieldStatic member One Represents a Rational object that is equal to 1.
Public fieldStatic member PositiveInfinity Represents a Rational object that is equal to positive infinity (+1, 0).
Public fieldStatic member UnsignedInfinity Represents a Rational object that is equal to unsigned infinity (+2, 0).
Public fieldStatic member 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.

See Also

Reference

Microsoft.SolverFoundation.Common Namespace