Struct GorgonRationalNumber
A representation of a rational number.
Inherited Members
Namespace: Gorgon.Math
Assembly: Gorgon.Core.dll
Syntax
public readonly struct GorgonRationalNumber : IEquatable<GorgonRationalNumber>, IComparable<GorgonRationalNumber>
Constructors
| Edit this page View SourceGorgonRationalNumber(int, int)
Initializes a new instance of the GorgonRationalNumber struct.
Declaration
public GorgonRationalNumber(int numerator, int denominator)
Parameters
Type | Name | Description |
---|---|---|
int | numerator | The numerator for the number. |
int | denominator | The denominator for the number. |
Exceptions
Type | Condition |
---|---|
DivideByZeroException | Thrown when the |
Fields
| Edit this page View SourceDenominator
The denominator for the number.
Declaration
public readonly int Denominator
Field Value
Type | Description |
---|---|
int |
Empty
An empty rational number.
Declaration
public static readonly GorgonRationalNumber Empty
Field Value
Type | Description |
---|---|
GorgonRationalNumber |
Numerator
The numerator for the number.
Declaration
public readonly int Numerator
Field Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceCompareTo(GorgonRationalNumber)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Declaration
public int CompareTo(GorgonRationalNumber other)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | other | An object to compare with this instance. |
Returns
Type | Description |
---|---|
int | A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes |
Equals(GorgonRationalNumber)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(GorgonRationalNumber other)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(GorgonRationalNumber, GorgonRationalNumber)
Function to compare two instances for equality.
Declaration
public static bool Equals(GorgonRationalNumber left, GorgonRationalNumber right)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | left | Left instance to compare. |
GorgonRationalNumber | right | Right instance to compare. |
Returns
Type | Description |
---|---|
bool | true if the instances are equal, false if not. |
Equals(object)
Determines whether the specified object is equal to the current object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Edit this page View SourceGetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
| Edit this page View SourceToDecimal(GorgonRationalNumber)
Function to perform an implicit conversion from GorgonRationalNumber to decimal.
Declaration
public static decimal ToDecimal(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
decimal | The result of the conversion. |
ToDouble(GorgonRationalNumber)
Function to perform an explicit conversion from GorgonRationalNumber to double.
Declaration
public static double ToDouble(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
double | The result of the conversion. |
ToGorgonRationalNumber(int)
Function to perform an implicit conversion from int to GorgonRationalNumber.
Declaration
public static GorgonRationalNumber ToGorgonRationalNumber(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to convert. |
Returns
Type | Description |
---|---|
GorgonRationalNumber | The result of the conversion. |
ToInt32(GorgonRationalNumber)
Function to perform an explicit conversion from GorgonRationalNumber to int.
Declaration
public static int ToInt32(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
int | The result of the conversion. |
ToSingle(GorgonRationalNumber)
Function to perform an explicit conversion from GorgonRationalNumber to float.
Declaration
public static float ToSingle(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
float | The result of the conversion. |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |
Overrides
Operators
| Edit this page View Sourceoperator ==(GorgonRationalNumber, GorgonRationalNumber)
Operator to compare two instances for equality.
Declaration
public static bool operator ==(GorgonRationalNumber left, GorgonRationalNumber right)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | left | Left instance to compare. |
GorgonRationalNumber | right | Right instance to compare. |
Returns
Type | Description |
---|---|
bool | true if equal, false if not. |
explicit operator double(GorgonRationalNumber)
Performs an explicit conversion from GorgonRationalNumber to double.
Declaration
public static explicit operator double(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
double | The result of the conversion. |
explicit operator int(GorgonRationalNumber)
Performs an explicit conversion from GorgonRationalNumber to int.
Declaration
public static explicit operator int(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
int | The result of the conversion. |
explicit operator float(GorgonRationalNumber)
Performs an explicit conversion from GorgonRationalNumber to float.
Declaration
public static explicit operator float(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
float | The result of the conversion. |
operator >(GorgonRationalNumber, GorgonRationalNumber)
Operator to determine if the left rational is greater than the right rational.
Declaration
public static bool operator >(GorgonRationalNumber left, GorgonRationalNumber right)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | left | Left rational to compare. |
GorgonRationalNumber | right | Right rational to compare. |
Returns
Type | Description |
---|---|
bool | true if the |
operator >=(GorgonRationalNumber, GorgonRationalNumber)
Operator to determine if the left rational is greater than or equal to the right rational.
Declaration
public static bool operator >=(GorgonRationalNumber left, GorgonRationalNumber right)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | left | Left rational to compare. |
GorgonRationalNumber | right | Right rational to compare. |
Returns
Type | Description |
---|---|
bool | true if the |
implicit operator decimal(GorgonRationalNumber)
Performs an implicit conversion from GorgonRationalNumber to decimal.
Declaration
public static implicit operator decimal(GorgonRationalNumber value)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | value | The value convert. |
Returns
Type | Description |
---|---|
decimal | The result of the conversion. |
implicit operator GorgonRationalNumber(int)
Performs an implicit conversion from int to GorgonRationalNumber.
Declaration
public static implicit operator GorgonRationalNumber(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to convert. |
Returns
Type | Description |
---|---|
GorgonRationalNumber | The result of the conversion. |
operator !=(GorgonRationalNumber, GorgonRationalNumber)
Operator to compare two instances for inequality.
Declaration
public static bool operator !=(GorgonRationalNumber left, GorgonRationalNumber right)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | left | Left instance to compare. |
GorgonRationalNumber | right | Right instance to compare. |
Returns
Type | Description |
---|---|
bool | true if not equal, false if equal. |
operator <(GorgonRationalNumber, GorgonRationalNumber)
Operator to determine if the left rational is less than the right rational.
Declaration
public static bool operator <(GorgonRationalNumber left, GorgonRationalNumber right)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | left | Left rational to compare. |
GorgonRationalNumber | right | Right rational to compare. |
Returns
Type | Description |
---|---|
bool | true if the |
operator <=(GorgonRationalNumber, GorgonRationalNumber)
Operator to determine if the left rational is less than or equal to the right rational.
Declaration
public static bool operator <=(GorgonRationalNumber left, GorgonRationalNumber right)
Parameters
Type | Name | Description |
---|---|---|
GorgonRationalNumber | left | Left rational to compare. |
GorgonRationalNumber | right | Right rational to compare. |
Returns
Type | Description |
---|---|
bool | true if the |