Struct Rational
Represents a rational number with a numerator and denominator. This struct is readonly for performance reasons.
Inherited Members
Namespace: FFmpeg.Utils
Assembly: FFmpeg.dll
Syntax
public readonly struct Rational : IEquatable<Rational>, IComparable<Rational>, IConvertible, IFormattable
Constructors
View SourceRational()
Initializes a new instance of the Rational struct with a value of 0/1.
Declaration
public Rational()
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. |
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 SourceEpsilon
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 SourceDenominator
Denominator of the rational number.
Declaration
public int Denominator { get; }
Property Value
| Type | Description |
|---|---|
| int |
Height
Height represented by the denominator.
Declaration
public int Height { get; }
Property Value
| Type | Description |
|---|---|
| int |
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 |
|
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 |
|
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 |
|
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 |
|
Numerator
Numerator of the rational number.
Declaration
public int Numerator { get; }
Property Value
| Type | Description |
|---|---|
| int |
Width
Width represented by the numerator.
Declaration
public int Width { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceCompareTo(Rational)
Declaration
public int CompareTo(Rational other)
Parameters
| Type | Name | Description |
|---|---|---|
| Rational | other |
Returns
| Type | Description |
|---|---|
| int |
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. |
Equals(Rational)
Declaration
public bool Equals(Rational other)
Parameters
| Type | Name | Description |
|---|---|---|
| Rational | other |
Returns
| Type | Description |
|---|---|
| bool | true if the current Rational is equal to the other parameter; otherwise, false. |
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
View SourceGetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code for the current Rational. |
Overrides
View SourceGreatestCommonDivisor(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 |
| Rational | default | A fallback rational value to return if the denominator of the GCD exceeds |
Returns
| Type | Description |
|---|---|
| Rational | A Rational representing the greatest common divisor of |
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 |
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:
|
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. |
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:
|
| 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. |
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. |
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. |
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. |
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
View SourceToString(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. |
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. |
ToString(string?, IFormatProvider?)
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:
|
| 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. |
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:
|
| Rational | value | An output parameter that will contain the parsed Rational if parsing succeeds, or NaN if it fails. |
Returns
| Type | Description |
|---|---|
| bool | Returns |
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:
|
| 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 |
Operators
View Sourceoperator +(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. |
operator /(Rational, 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. |
operator /(TimeSpan, Rational)
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. |
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. |
operator ==(Rational, TimeSpan)
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. |
operator ==(TimeSpan, Rational)
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. |
explicit operator int(Rational)
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. |
explicit operator long(Rational)
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. |
explicit operator Rational(long)
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 |
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. |
operator >(Rational, TimeSpan)
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. |
operator >(TimeSpan, Rational)
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. |
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. |
operator >=(Rational, TimeSpan)
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. |
operator >=(TimeSpan, Rational)
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. |
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 |
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 |
implicit operator double(Rational)
Declaration
public static implicit operator double(Rational r)
Parameters
| Type | Name | Description |
|---|---|---|
| Rational | r |
Returns
| Type | Description |
|---|---|
| double |
implicit operator TimeSpan(Rational)
Declaration
public static implicit operator TimeSpan(Rational r)
Parameters
| Type | Name | Description |
|---|---|---|
| Rational | r |
Returns
| Type | Description |
|---|---|
| TimeSpan |
implicit operator Rational(double)
Declaration
public static implicit operator Rational(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value |
Returns
| Type | Description |
|---|---|
| Rational |
implicit operator Rational(int)
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 |
implicit operator Rational(TimeSpan)
Declaration
public static implicit operator Rational(TimeSpan timeSpan)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeSpan |
Returns
| Type | Description |
|---|---|
| Rational |
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 |
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 |
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. |
operator !=(Rational, TimeSpan)
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. |
operator !=(TimeSpan, Rational)
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. |
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. |
operator <(Rational, TimeSpan)
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. |
operator <(TimeSpan, Rational)
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. |
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. |
operator <=(Rational, TimeSpan)
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. |
operator <=(TimeSpan, Rational)
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. |
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. |
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. |
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. |
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. |