Table of Contents

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

value double

The double to create the instance from.

SignedRational(double, bool)

Initializes a new instance of the SignedRational struct.

public SignedRational(double value, bool bestPrecision)

Parameters

value double

The double to create the instance from.

bestPrecision bool

Whether 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

value int

The int to create the rational from.

SignedRational(int, int)

Initializes a new instance of the SignedRational struct.

public SignedRational(int numerator, int denominator)

Parameters

numerator int

The number above the line in a vulgar fraction showing how many of the parts indicated by the denominator are taken.

denominator int

The 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 int

The number above the line in a vulgar fraction showing how many of the parts indicated by the denominator are taken.

denominator int

The number below the line in a vulgar fraction; a divisor.

simplify bool

Specified if the rational should be simplified.

Properties

Denominator

Gets the denominator of a number.

public int Denominator { get; }

Property Value

int

Numerator

Gets the numerator of a number.

public int Numerator { get; }

Property Value

int

Methods

Equals(SignedRational)

public bool Equals(SignedRational other)

Parameters

other SignedRational

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromDouble(double)

Converts the specified double to an instance of this type.

public static SignedRational FromDouble(double value)

Parameters

value double

The double to convert to an instance of this type.

Returns

SignedRational

The SignedRational.

FromDouble(double, bool)

Converts the specified double to an instance of this type.

public static SignedRational FromDouble(double value, bool bestPrecision)

Parameters

value double

The double to convert to an instance of this type.

bestPrecision bool

Whether to use the best possible precision when parsing the value.

Returns

SignedRational

The SignedRational.

GetHashCode()

public override int GetHashCode()

Returns

int

ToDouble()

Converts a rational number to the nearest double.

public double ToDouble()

Returns

double

The double.

ToString()

public override string ToString()

Returns

string

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 IFormatProvider

An object that supplies culture-specific formatting information.

Returns

string

The string

Operators

operator ==(SignedRational, SignedRational)

Determines whether the specified SignedRational instances are considered equal.

public static bool operator ==(SignedRational left, SignedRational right)

Parameters

left SignedRational

The first SignedRational to compare.

right SignedRational

The second SignedRational to compare.

Returns

bool

The bool

operator !=(SignedRational, SignedRational)

Determines whether the specified SignedRational instances are not considered equal.

public static bool operator !=(SignedRational left, SignedRational right)

Parameters

left SignedRational

The first SignedRational to compare.

right SignedRational

The second SignedRational to compare.

Returns

bool

The bool