Struct SignedRational
Represents a number that can be expressed as a fraction.
Implements
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public readonly struct SignedRational
Remarks
This is a very simplified implementation of a rational number designed for use with metadata only.
Constructors
| Improve this Doc View SourceSignedRational(Double)
Initializes a new instance of the SignedRational struct.
Declaration
public SignedRational(double value)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The |
SignedRational(Double, Boolean)
Initializes a new instance of the SignedRational struct.
Declaration
public SignedRational(double value, bool bestPrecision)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The |
Boolean | bestPrecision | Whether to use the best possible precision when parsing the value. |
SignedRational(Int32)
Initializes a new instance of the SignedRational struct.
Declaration
public SignedRational(int value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | The |
SignedRational(Int32, Int32)
Initializes a new instance of the SignedRational struct.
Declaration
public SignedRational(int numerator, int denominator)
Parameters
Type | Name | Description |
---|---|---|
Int32 | numerator | The number above the line in a vulgar fraction showing how many of the parts indicated by the denominator are taken. |
Int32 | denominator | The number below the line in a vulgar fraction; a divisor. |
SignedRational(Int32, Int32, Boolean)
Initializes a new instance of the SignedRational struct.
Declaration
public SignedRational(int numerator, int denominator, bool simplify)
Parameters
Type | Name | Description |
---|---|---|
Int32 | numerator | The number above the line in a vulgar fraction showing how many of the parts indicated by the denominator are taken. |
Int32 | denominator | The number below the line in a vulgar fraction; a divisor. |
Boolean | simplify | Specified if the rational should be simplified. |
Properties
| Improve this Doc View SourceDenominator
Gets the denominator of a number.
Declaration
public readonly int Denominator { get; }
Property Value
Type | Description |
---|---|
Int32 |
Numerator
Gets the numerator of a number.
Declaration
public readonly int Numerator { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
| Improve this Doc View SourceEquals(SignedRational)
Declaration
public readonly bool Equals(SignedRational other)
Parameters
Type | Name | Description |
---|---|---|
SignedRational | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Nullable<Object>)
Declaration
public override readonly bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
Nullable<Object> | obj |
Returns
Type | Description |
---|---|
Boolean |
FromDouble(Double)
Converts the specified
Declaration
public static SignedRational FromDouble(double value)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The |
Returns
Type | Description |
---|---|
SignedRational | The SignedRational. |
FromDouble(Double, Boolean)
Converts the specified
Declaration
public static SignedRational FromDouble(double value, bool bestPrecision)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The |
Boolean | bestPrecision | Whether to use the best possible precision when parsing the value. |
Returns
Type | Description |
---|---|
SignedRational | The SignedRational. |
GetHashCode()
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
ToDouble()
Converts a rational number to the nearest
Declaration
public readonly double ToDouble()
Returns
Type | Description |
---|---|
Double | The |
ToString()
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
String |
ToString(IFormatProvider)
Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
Declaration
public readonly string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
IFormatProvider | provider | An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
String | The |
Operators
| Improve this Doc View SourceEquality(SignedRational, SignedRational)
Determines whether the specified SignedRational instances are considered equal.
Declaration
public static bool operator ==(SignedRational left, SignedRational right)
Parameters
Type | Name | Description |
---|---|---|
SignedRational | left | The first SignedRational to compare. |
SignedRational | right | The second SignedRational to compare. |
Returns
Type | Description |
---|---|
Boolean | The |
Inequality(SignedRational, SignedRational)
Determines whether the specified SignedRational instances are not considered equal.
Declaration
public static bool operator !=(SignedRational left, SignedRational right)
Parameters
Type | Name | Description |
---|---|---|
SignedRational | left | The first SignedRational to compare. |
SignedRational | right | The second SignedRational to compare. |
Returns
Type | Description |
---|---|
Boolean | The |