Struct SignedRational
Represents a number that can be expressed as a fraction.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public readonly struct SignedRational : IEquatable<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 Double to create the instance from. |
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 Double to create the instance from. |
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 Int32 to create the rational from. |
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(Object)
Declaration
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceFromDouble(Double)
Converts the specified Double to an instance of this type.
Declaration
public static SignedRational FromDouble(double value)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The Double to convert to an instance of this type. |
Returns
Type | Description |
---|---|
SignedRational | The SignedRational. |
FromDouble(Double, Boolean)
Converts the specified Double to an instance of this type.
Declaration
public static SignedRational FromDouble(double value, bool bestPrecision)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The Double to convert to an instance of this type. |
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 |
Overrides
| Improve this Doc View SourceToDouble()
Converts a rational number to the nearest Double.
Declaration
public readonly double ToDouble()
Returns
Type | Description |
---|---|
Double | The Double. |
ToString()
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
| Improve this Doc View SourceToString(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 String |
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 Boolean |
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 Boolean |