Struct SignedRational
- Namespace
- SixLabors.ImageSharp
- Assembly
- SixLabors.ImageSharp.dll
Represents a number that can be expressed as a fraction.
public readonly struct SignedRational : IEquatable<SignedRational>
- Implements
- Inherited Members
Remarks
This is a very simplified implementation of a rational number designed for use with metadata only.
Constructors
SignedRational(double)
Initializes a new instance of the SignedRational struct.
public SignedRational(double value)
Parameters
SignedRational(double, bool)
Initializes a new instance of the SignedRational struct.
public SignedRational(double value, bool bestPrecision)
Parameters
value
doubleThe double to create the instance from.
bestPrecision
boolWhether to use the best possible precision when parsing the value.
SignedRational(int)
Initializes a new instance of the SignedRational struct.
public SignedRational(int value)
Parameters
SignedRational(int, int)
Initializes a new instance of the SignedRational struct.
public SignedRational(int numerator, int denominator)
Parameters
numerator
intThe number above the line in a vulgar fraction showing how many of the parts indicated by the denominator are taken.
denominator
intThe number below the line in a vulgar fraction; a divisor.
SignedRational(int, int, bool)
Initializes a new instance of the SignedRational struct.
public SignedRational(int numerator, int denominator, bool simplify)
Parameters
numerator
intThe number above the line in a vulgar fraction showing how many of the parts indicated by the denominator are taken.
denominator
intThe number below the line in a vulgar fraction; a divisor.
simplify
boolSpecified if the rational should be simplified.
Properties
Denominator
Gets the denominator of a number.
public int Denominator { get; }
Property Value
Numerator
Gets the numerator of a number.
public int Numerator { get; }
Property Value
Methods
Equals(SignedRational)
public bool Equals(SignedRational other)
Parameters
other
SignedRational
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
Returns
FromDouble(double)
Converts the specified double to an instance of this type.
public static SignedRational FromDouble(double value)
Parameters
Returns
FromDouble(double, bool)
Converts the specified double to an instance of this type.
public static SignedRational FromDouble(double value, bool bestPrecision)
Parameters
value
doubleThe double to convert to an instance of this type.
bestPrecision
boolWhether to use the best possible precision when parsing the value.
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToDouble()
Converts a rational number to the nearest double.
public double ToDouble()
Returns
ToString()
public override string ToString()
Returns
ToString(IFormatProvider)
Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
public string ToString(IFormatProvider provider)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
Returns
Operators
operator ==(SignedRational, SignedRational)
Determines whether the specified SignedRational instances are considered equal.
public static bool operator ==(SignedRational left, SignedRational right)
Parameters
left
SignedRationalThe first SignedRational to compare.
right
SignedRationalThe second SignedRational to compare.
Returns
operator !=(SignedRational, SignedRational)
Determines whether the specified SignedRational instances are not considered equal.
public static bool operator !=(SignedRational left, SignedRational right)
Parameters
left
SignedRationalThe first SignedRational to compare.
right
SignedRationalThe second SignedRational to compare.