Show / Hide Table of Contents

Struct Rational

Represents a rational number with a numerator and denominator. This struct is readonly for performance reasons.

Implements
IEquatable<Rational>
IComparable<Rational>
IConvertible
IFormattable
Inherited Members
object.GetType()
object.Equals(object, object)
object.ReferenceEquals(object, object)
Namespace: FFmpeg.Utils
Assembly: FFmpeg.dll
Syntax
public readonly struct Rational : IEquatable<Rational>, IComparable<Rational>, IConvertible, IFormattable

Constructors

View Source

Rational()

Initializes a new instance of the Rational struct with a value of 0/1.

Declaration
public Rational()
View Source

Rational(int, int)

Initializes a new instance of the Rational struct with the specified numerator and denominator.

Declaration
public Rational(int numerator, int denominator)
Parameters
Type Name Description
int numerator

The numerator.

int denominator

The denominator.

Exceptions
Type Condition
DivideByZeroException

Thrown when the denominator is zero.

View Source

Rational(long, long)

Initializes a new instance of the Rational struct using a long numerator and denominator, reducing the result.

Declaration
public Rational(long numerator, long denominator)
Parameters
Type Name Description
long numerator

The numerator.

long denominator

The denominator.

Fields

View Source

Epsilon

Represents the smallest possible positive value for a rational number, defined as 1/MaxValue. This value is used to represent the smallest non-zero rational value.

Declaration
public static readonly Rational Epsilon
Field Value
Type Description
Rational
View Source

MaxValue

Represents the maximum possible value for a rational number, using MaxValue as the numerator and 1 as the denominator.

Declaration
public static readonly Rational MaxValue
Field Value
Type Description
Rational
View Source

MinValue

Represents the minimum possible value for a rational number, using MinValue as the numerator and 1 as the denominator.

Declaration
public static readonly Rational MinValue
Field Value
Type Description
Rational
View Source

NaN

Represents NaN (Not-a-Number) as a rational number (0/0). This is used to represent an undefined or unrepresentable value.

Declaration
public static readonly Rational NaN
Field Value
Type Description
Rational
View Source

NegativeInfinity

Represents negative infinity as a rational number (-1/0). This is used to represent an infinitely large negative value.

Declaration
public static readonly Rational NegativeInfinity
Field Value
Type Description
Rational
View Source

PositiveInfinity

Represents positive infinity as a rational number (1/0). This is used to represent an infinitely large positive value.

Declaration
public static readonly Rational PositiveInfinity
Field Value
Type Description
Rational
View Source

TIME_BASE

Represents the time base used by the Rational structure. It is a rational number with a numerator of 1 and a denominator of FFmpeg.AutoGen.ffmpeg.AV_TIME_BASE. This value is commonly used in time-based calculations in multimedia processing and represents the ffmpegs default time base.

Declaration
public static readonly Rational TIME_BASE
Field Value
Type Description
Rational
View Source

Zero

Represents the rational number zero (0/1). This value is commonly used to represent a zero rational value.

Declaration
public static readonly Rational Zero
Field Value
Type Description
Rational

Properties

View Source

Denominator

Denominator of the rational number.

Declaration
public int Denominator { get; }
Property Value
Type Description
int
View Source

Height

Height represented by the denominator.

Declaration
public int Height { get; }
Property Value
Type Description
int
View Source

IsNaN

Indicates whether the rational number is NaN (Not-a-Number). A rational number is considered NaN if both its numerator and denominator are zero.

Declaration
public bool IsNaN { get; }
Property Value
Type Description
bool

true if the rational number is NaN, otherwise false.

View Source

IsNegativeInfinity

Indicates whether the rational number is negative infinity. A rational number is considered negative infinity if its numerator is less than zero and its denominator is zero.

Declaration
public bool IsNegativeInfinity { get; }
Property Value
Type Description
bool

true if the rational number is negative infinity, otherwise false.

View Source

IsPositiveInfinity

Indicates whether the rational number is positive infinity. A rational number is considered positive infinity if its numerator is greater than zero and its denominator is zero.

Declaration
public bool IsPositiveInfinity { get; }
Property Value
Type Description
bool

true if the rational number is positive infinity, otherwise false.

View Source

IsValidTimeBase

Indicates whether the rational number represents a valid time base. A valid time base is defined as having both a positive numerator and denominator.

Declaration
public bool IsValidTimeBase { get; }
Property Value
Type Description
bool

true if the rational number represents a valid time base (i.e., both numerator and denominator are positive), otherwise false.

View Source

Numerator

Numerator of the rational number.

Declaration
public int Numerator { get; }
Property Value
Type Description
int
View Source

Width

Width represented by the numerator.

Declaration
public int Width { get; }
Property Value
Type Description
int

Methods

View Source

CompareTo(Rational)

Declaration
public int CompareTo(Rational other)
Parameters
Type Name Description
Rational other
Returns
Type Description
int
View Source

Deconstruct(out int, out int)

Deconstructs the Rational into its numerator and denominator components. This method allows for easy extraction of the numerator and denominator when using tuple deconstruction syntax.

Declaration
public void Deconstruct(out int numerator, out int denominator)
Parameters
Type Name Description
int numerator

The numerator of the Rational instance.

int denominator

The denominator of the Rational instance.

View Source

Equals(Rational)

Determines whether the current Rational is equal to another Rational.

Declaration
public bool Equals(Rational other)
Parameters
Type Name Description
Rational other

The Rational to compare with the current Rational.

Returns
Type Description
bool

true if the current Rational is equal to the other parameter; otherwise, false.

View Source

Equals(object?)

Determines whether the current Rational is equal to another object.

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj

The object to compare with the current Rational.

Returns
Type Description
bool

true if the specified object is equal to the current Rational; otherwise, false.

Overrides
ValueType.Equals(object)
View Source

GetHashCode()

Serves as the default hash function.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for the current Rational.

Overrides
ValueType.GetHashCode()
View Source

GreatestCommonDivisor(Rational, Rational, int, Rational)

Returns the greatest common divisor (GCD) of two rational numbers a and b. The GCD is chosen so that both numbers are multiples of it. If the resulting denominator exceeds the specified max_den, the method will return the provided default rational value.

Declaration
public static Rational GreatestCommonDivisor(Rational a, Rational b, int max_den, Rational @default)
Parameters
Type Name Description
Rational a

The first rational number for which the GCD is to be calculated.

Rational b

The second rational number for which the GCD is to be calculated.

int max_den

The maximum allowable denominator for the resulting GCD. If the denominator of the GCD exceeds this value, the method will return default.

Rational default

A fallback rational value to return if the denominator of the GCD exceeds max_den.

Returns
Type Description
Rational

A Rational representing the greatest common divisor of a and b. If the GCD has a denominator larger than max_den, returns default.

View Source

GreatestCommonDivisor(long, long)

Returns the greatest common divisor (GCD) of two integers a and b.

Declaration
public static long GreatestCommonDivisor(long a, long b)
Parameters
Type Name Description
long a

The first integer for which the GCD is to be calculated.

long b

The second integer for which the GCD is to be calculated.

Returns
Type Description
long

The greatest common divisor of a and b.

View Source

Parse(ReadOnlySpan<char>)

Parses a Rational from a string representation (in the form of a ReadOnlySpan<T>). Throws a FormatException if parsing fails.

Declaration
public static Rational Parse(ReadOnlySpan<char> s)
Parameters
Type Name Description
ReadOnlySpan<char> s

A ReadOnlySpan<T> representing the string to be parsed. The string should be in the format of either:

  • A rational number "numerator/denominator" (e.g., "1/2")
  • A decimal value (e.g., "3.14")
Returns
Type Description
Rational

A Rational representing the parsed value.

Exceptions
Type Condition
FormatException

Thrown when the string cannot be parsed into a valid Rational.

View Source

Parse(ReadOnlySpan<char>, IFormatProvider?)

Parses a Rational from a string representation (in the form of a ReadOnlySpan<T>), using a specified culture-specific formatting provider. Throws a FormatException if parsing fails.

Declaration
public static Rational Parse(ReadOnlySpan<char> s, IFormatProvider? provider)
Parameters
Type Name Description
ReadOnlySpan<char> s

A ReadOnlySpan<T> representing the string to be parsed. The string should be in the format of either:

  • A rational number "numerator/denominator" (e.g., "1/2")
  • A decimal value (e.g., "3.14")
IFormatProvider provider

An optional IFormatProvider used to parse the string according to specific culture settings (e.g., decimal separators).

Returns
Type Description
Rational

A Rational representing the parsed value.

Exceptions
Type Condition
FormatException

Thrown when the string cannot be parsed into a valid Rational.

View Source

Reduce(int)

Reduces the Rational number to its simplest form, considering a maximum value for the numerator and denominator.

Declaration
public Rational Reduce(int max)
Parameters
Type Name Description
int max

The maximum allowed value for the numerator and denominator.

Returns
Type Description
Rational

A reduced Rational number.

View Source

Rescale(long, Rational)

Rescales a 64-bit integer from a specific source time base to the current instance's time base.
This operation is mathematically equivalent to value * timeBaseSrc / this, where this refers to the current time base.

Declaration
public long Rescale(long value, Rational timeBaseSrc)
Parameters
Type Name Description
long value

The 64-bit integer value to be rescaled.

Rational timeBaseSrc

The source time base (rational number).

Returns
Type Description
long

The rescaled value in the current instance's time base units.

View Source

Rescale(long, Rational, Rational)

Rescales a 64-bit integer according to two rational time bases.
This operation is mathematically equivalent to value * timeBaseSrc / timeBaseDst.

Declaration
public static long Rescale(long value, Rational timeBaseSrc, Rational timeBaseDst)
Parameters
Type Name Description
long value

The 64-bit integer value to be rescaled.

Rational timeBaseSrc

The source time base (rational number).

Rational timeBaseDst

The destination time base (rational number).

Returns
Type Description
long

The rescaled value in the destination time base units.

View Source

ToString()

Returns a string representation of the Rational number.

Declaration
public override string ToString()
Returns
Type Description
string

A string in the format "numerator/denominator".

Overrides
ValueType.ToString()
View Source

ToString(IFormatProvider?)

Converts this Rational instance to a string representation, using the default format and the specified culture-specific formatting.

Declaration
public string ToString(IFormatProvider? provider)
Parameters
Type Name Description
IFormatProvider provider

An object that supplies culture-specific formatting information. If null, the default culture is used.

Returns
Type Description
string

A string representing the rational number in the specified culture format.

View Source

ToString(string?)

Converts this Rational instance to a string representation, using the default format and no culture-specific formatting.

Declaration
public string ToString(string? format)
Parameters
Type Name Description
string format

A custom format string. If null or empty, the rational number is represented as "{numerator}/{denominator}".

Returns
Type Description
string

A string representing the rational number in the specified format.

View Source

ToString(string?, IFormatProvider?)

Converts this Rational instance to a string representation.

Declaration
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
Type Name Description
string format

A custom format string that determines how the rational number is converted to a string. The format string can specify the following:

  • If the first character is 'D' or 'd', followed by a double format (e.g., "D2"), the result will be a string representing the rational number as a double with the specified format. If the format string is just 'D' or 'd' (without any digits), the result will be a string representing the rational number as a double, using the default format for doubles.
  • If the first character is a delimiter (e.g., '/', '-', etc.), followed by an integer format (e.g., "F0"), the result will be a string formatted as "{numerator:format}{delimiter}{denominator:format}".
  • If the format string is empty or null, the method will return the rational number as a string in the format "{numerator}/{denominator}".
IFormatProvider formatProvider

An object that supplies culture-specific formatting information. This is used to format both the numerator and denominator according to the specified format.

Returns
Type Description
string

A string representing the rational number in the specified format.

View Source

TryParse(ReadOnlySpan<char>, out Rational)

Tries to parse a Rational from a string representation (in the form of a ReadOnlySpan<T>). If successful, the parsed Rational is returned in the out parameter.

Declaration
public static bool TryParse(ReadOnlySpan<char> s, out Rational value)
Parameters
Type Name Description
ReadOnlySpan<char> s

A ReadOnlySpan<T> representing the string to be parsed. The string should be in the format of either:

  • A rational number "numerator/denominator" (e.g., "1/2")
  • A decimal value (e.g., "3.14")
Rational value

An output parameter that will contain the parsed Rational if parsing succeeds, or NaN if it fails.

Returns
Type Description
bool

Returns true if the parsing was successful, otherwise false.

View Source

TryParse(ReadOnlySpan<char>, IFormatProvider?, out Rational)

Tries to parse a Rational from a string representation (in the form of a ReadOnlySpan<T>), using a specified culture-specific formatting provider.

Declaration
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out Rational value)
Parameters
Type Name Description
ReadOnlySpan<char> s

A ReadOnlySpan<T> representing the string to be parsed. The string should be in the format of either:

  • A rational number "numerator/denominator" (e.g., "1/2")
  • A decimal value (e.g., "3.14")
IFormatProvider provider

An optional IFormatProvider used to parse the string according to specific culture settings (e.g., decimal separators).

Rational value

An output parameter that will contain the parsed Rational if parsing succeeds, or NaN if it fails.

Returns
Type Description
bool

Returns true if the parsing was successful, otherwise false.

Operators

View Source

operator +(Rational, Rational)

Adds two rational numbers together, returning their sum as a new Rational. The result is calculated by finding a common denominator and adding the numerators.

Declaration
public static Rational operator +(Rational a, Rational b)
Parameters
Type Name Description
Rational a

The first rational number to be added.

Rational b

The second rational number to be added.

Returns
Type Description
Rational

A new Rational representing the sum of the two rational numbers.

View Source

operator /(Rational, Rational)

Divides one Rational number by another, returning the result as a new Rational.

Declaration
public static Rational operator /(Rational r1, Rational r2)
Parameters
Type Name Description
Rational r1

The Rational number to divide (numerator).

Rational r2

The Rational number by which to divide (denominator).

Returns
Type Description
Rational

A new Rational representing the quotient of the two rational numbers.

View Source

operator /(TimeSpan, Rational)

Divides a TimeSpan by a Rational number, returning the quotient as a long.

Declaration
public static long operator /(TimeSpan t, Rational r2)
Parameters
Type Name Description
TimeSpan t

The TimeSpan to divide.

Rational r2

The Rational divisor.

Returns
Type Description
long

A long representing the result of dividing the TimeSpan by the Rational.

View Source

operator ==(Rational, Rational)

Compares two Rational numbers for equality.

Declaration
public static bool operator ==(Rational left, Rational right)
Parameters
Type Name Description
Rational left

The first Rational number to compare.

Rational right

The second Rational number to compare.

Returns
Type Description
bool

True if the two Rational numbers are equal; otherwise, false.

View Source

operator ==(Rational, TimeSpan)

Compares a Rational with a TimeSpan for equality.

Declaration
public static bool operator ==(Rational rational, TimeSpan timeSpan)
Parameters
Type Name Description
Rational rational

The Rational number to compare.

TimeSpan timeSpan

The TimeSpan to compare.

Returns
Type Description
bool

True if the two are equal; otherwise, false.

View Source

operator ==(TimeSpan, Rational)

Compares a TimeSpan with a Rational for equality.

Declaration
public static bool operator ==(TimeSpan timeSpan, Rational rational)
Parameters
Type Name Description
TimeSpan timeSpan

The TimeSpan to compare.

Rational rational

The Rational number to compare.

Returns
Type Description
bool

True if the two are equal; otherwise, false.

View Source

explicit operator int(Rational)

Explicitly converts a Rational to an int by truncating its fractional part.

Declaration
public static explicit operator int(Rational r)
Parameters
Type Name Description
Rational r

The Rational value to convert.

Returns
Type Description
int

The integral part of the rational value, truncated toward zero.

View Source

explicit operator long(Rational)

Explicitly converts a Rational to a long by truncating its fractional part.

Declaration
public static explicit operator long(Rational r)
Parameters
Type Name Description
Rational r

The Rational value to convert.

Returns
Type Description
long

The integral part of the rational value, truncated toward zero.

View Source

explicit operator Rational(long)

Explicitly converts a long to a Rational.

Declaration
public static explicit operator Rational(long l)
Parameters
Type Name Description
long l

The integer value to convert.

Returns
Type Description
Rational

A Rational representing l with a denominator of 1.

View Source

operator >(Rational, Rational)

Compares two Rational numbers for greater than.

Declaration
public static bool operator >(Rational left, Rational right)
Parameters
Type Name Description
Rational left

The first Rational number to compare.

Rational right

The second Rational number to compare.

Returns
Type Description
bool

True if the first Rational is greater than the second; otherwise, false.

View Source

operator >(Rational, TimeSpan)

Compares a Rational number with a TimeSpan for greater than.

Declaration
public static bool operator >(Rational rational, TimeSpan timeSpan)
Parameters
Type Name Description
Rational rational

The Rational number to compare.

TimeSpan timeSpan

The TimeSpan to compare.

Returns
Type Description
bool

True if the Rational is greater than the TimeSpan; otherwise, false.

View Source

operator >(TimeSpan, Rational)

Compares a TimeSpan with a Rational for greater than.

Declaration
public static bool operator >(TimeSpan timeSpan, Rational rational)
Parameters
Type Name Description
TimeSpan timeSpan

The TimeSpan to compare.

Rational rational

The Rational number to compare.

Returns
Type Description
bool

True if the TimeSpan is greater than the Rational; otherwise, false.

View Source

operator >=(Rational, Rational)

Compares two Rational numbers for greater than or equal to.

Declaration
public static bool operator >=(Rational left, Rational right)
Parameters
Type Name Description
Rational left

The first Rational number to compare.

Rational right

The second Rational number to compare.

Returns
Type Description
bool

True if the first Rational is greater than or equal to the second; otherwise, false.

View Source

operator >=(Rational, TimeSpan)

Compares a Rational number with a TimeSpan for greater than or equal to.

Declaration
public static bool operator >=(Rational rational, TimeSpan timeSpan)
Parameters
Type Name Description
Rational rational

The Rational number to compare.

TimeSpan timeSpan

The TimeSpan to compare.

Returns
Type Description
bool

True if the Rational is greater than or equal to the TimeSpan; otherwise, false.

View Source

operator >=(TimeSpan, Rational)

Compares a TimeSpan with a Rational for greater than or equal to.

Declaration
public static bool operator >=(TimeSpan timeSpan, Rational rational)
Parameters
Type Name Description
TimeSpan timeSpan

The TimeSpan to compare.

Rational rational

The Rational number to compare.

Returns
Type Description
bool

True if the TimeSpan is greater than or equal to the Rational; otherwise, false.

View Source

implicit operator Rational(_AVRational)

Implicitly converts an FFmpeg.AutoGen._AVRational to a Rational.

Declaration
public static implicit operator Rational(_AVRational r)
Parameters
Type Name Description
_AVRational r
Returns
Type Description
Rational
View Source

implicit operator _AVRational(Rational)

Implicitly converts a Rational to an FFmpeg.AutoGen._AVRational.

Declaration
public static implicit operator _AVRational(Rational r)
Parameters
Type Name Description
Rational r
Returns
Type Description
_AVRational
View Source

implicit operator double(Rational)

Implicitly converts a Rational to a double.

Declaration
public static implicit operator double(Rational r)
Parameters
Type Name Description
Rational r
Returns
Type Description
double
View Source

implicit operator TimeSpan(Rational)

Implicitly converts a Rational to a TimeSpan.

Declaration
public static implicit operator TimeSpan(Rational r)
Parameters
Type Name Description
Rational r
Returns
Type Description
TimeSpan
View Source

implicit operator Rational(double)

Implicitly converts a double to a Rational.

Declaration
public static implicit operator Rational(double value)
Parameters
Type Name Description
double value
Returns
Type Description
Rational
View Source

implicit operator Rational(int)

Implicitly converts an int to a Rational.

Declaration
public static implicit operator Rational(int i)
Parameters
Type Name Description
int i

The integer value to convert.

Returns
Type Description
Rational

A Rational representing i with a denominator of 1.

View Source

implicit operator Rational(TimeSpan)

Implicitly converts a TimeSpan to a Rational.

Declaration
public static implicit operator Rational(TimeSpan timeSpan)
Parameters
Type Name Description
TimeSpan timeSpan
Returns
Type Description
Rational
View Source

implicit operator Rational((int numerator, int denominator))

Implicitly converts a tuple of int (numerator, denominator) to a Rational.

Declaration
public static implicit operator Rational((int numerator, int denominator) value)
Parameters
Type Name Description
(int Width, int Height) value
Returns
Type Description
Rational
View Source

implicit operator Rational((long numerator, long denominator))

Explicitly converts a tuple of long(numerator, denominator) to a Rational.

Declaration
public static implicit operator Rational((long numerator, long denominator) value)
Parameters
Type Name Description
(long numerator, long denominator) value
Returns
Type Description
Rational
View Source

operator !=(Rational, Rational)

Compares two Rational numbers for inequality.

Declaration
public static bool operator !=(Rational left, Rational right)
Parameters
Type Name Description
Rational left

The first Rational number to compare.

Rational right

The second Rational number to compare.

Returns
Type Description
bool

True if the two Rational numbers are not equal; otherwise, false.

View Source

operator !=(Rational, TimeSpan)

Compares a Rational with a TimeSpan for inequality.

Declaration
public static bool operator !=(Rational rational, TimeSpan timeSpan)
Parameters
Type Name Description
Rational rational

The Rational number to compare.

TimeSpan timeSpan

The TimeSpan to compare.

Returns
Type Description
bool

True if the two are not equal; otherwise, false.

View Source

operator !=(TimeSpan, Rational)

Compares a TimeSpan with a Rational for inequality.

Declaration
public static bool operator !=(TimeSpan timeSpan, Rational rational)
Parameters
Type Name Description
TimeSpan timeSpan

The TimeSpan to compare.

Rational rational

The Rational number to compare.

Returns
Type Description
bool

True if the two are not equal; otherwise, false.

View Source

operator <(Rational, Rational)

Compares two Rational numbers for less than.

Declaration
public static bool operator <(Rational left, Rational right)
Parameters
Type Name Description
Rational left

The first Rational number to compare.

Rational right

The second Rational number to compare.

Returns
Type Description
bool

True if the first Rational is less than the second; otherwise, false.

View Source

operator <(Rational, TimeSpan)

Compares a Rational number with a TimeSpan for less than.

Declaration
public static bool operator <(Rational rational, TimeSpan timeSpan)
Parameters
Type Name Description
Rational rational

The Rational number to compare.

TimeSpan timeSpan

The TimeSpan to compare.

Returns
Type Description
bool

True if the Rational is less than the TimeSpan; otherwise, false.

View Source

operator <(TimeSpan, Rational)

Compares a TimeSpan with a Rational for less than.

Declaration
public static bool operator <(TimeSpan timeSpan, Rational rational)
Parameters
Type Name Description
TimeSpan timeSpan

The TimeSpan to compare.

Rational rational

The Rational number to compare.

Returns
Type Description
bool

True if the TimeSpan is less than the Rational; otherwise, false.

View Source

operator <=(Rational, Rational)

Compares two Rational numbers for less than or equal to.

Declaration
public static bool operator <=(Rational left, Rational right)
Parameters
Type Name Description
Rational left

The first Rational number to compare.

Rational right

The second Rational number to compare.

Returns
Type Description
bool

True if the first Rational is less than or equal to the second; otherwise, false.

View Source

operator <=(Rational, TimeSpan)

Compares a Rational number with a TimeSpan for less than or equal to.

Declaration
public static bool operator <=(Rational rational, TimeSpan timeSpan)
Parameters
Type Name Description
Rational rational

The Rational number to compare.

TimeSpan timeSpan

The TimeSpan to compare.

Returns
Type Description
bool

True if the Rational is less than or equal to the TimeSpan; otherwise, false.

View Source

operator <=(TimeSpan, Rational)

Compares a TimeSpan with a Rational for less than or equal to.

Declaration
public static bool operator <=(TimeSpan timeSpan, Rational rational)
Parameters
Type Name Description
TimeSpan timeSpan

The TimeSpan to compare.

Rational rational

The Rational number to compare.

Returns
Type Description
bool

True if the TimeSpan is less than or equal to the Rational; otherwise, false.

View Source

operator *(Rational, Rational)

Multiplies two Rational numbers.

Declaration
public static Rational operator *(Rational r1, Rational r2)
Parameters
Type Name Description
Rational r1

The first Rational number to multiply.

Rational r2

The second Rational number to multiply.

Returns
Type Description
Rational

A new Rational that represents the product of the two rational numbers.

View Source

operator *(int, Rational)

Multiplies an integer by a Rational.

Declaration
public static Rational operator *(int value, Rational r)
Parameters
Type Name Description
int value

The integer to multiply with the rational number.

Rational r

The Rational number to multiply.

Returns
Type Description
Rational

A new Rational that represents the product of the integer and the rational number.

View Source

operator *(long, Rational)

Multiplies a long integer by a Rational.

Declaration
public static Rational operator *(long value, Rational r)
Parameters
Type Name Description
long value

The long integer to multiply with the rational number.

Rational r

The Rational number to multiply.

Returns
Type Description
Rational

A new Rational that represents the product of the long integer and the rational number.

View Source

operator -(Rational, Rational)

Subtracts one rational number from another, returning the result as a new Rational. The result is calculated by finding a common denominator and subtracting the numerators.

Declaration
public static Rational operator -(Rational a, Rational b)
Parameters
Type Name Description
Rational a

The rational number to subtract from (minuend).

Rational b

The rational number to subtract (subtrahend).

Returns
Type Description
Rational

A new Rational representing the difference between the two rational numbers.

Implements

IEquatable<T>
IComparable<T>
IConvertible
IFormattable
  • View Source
In this article
Back to top Generated by DocFX