Table of Contents

Struct RationalValue

Namespace
xFunc.Maths.Expressions
Assembly
xFunc.Maths.dll

Represents the rational number.

public readonly struct RationalValue : IEquatable<RationalValue>, IComparable<RationalValue>, IComparable
Implements
Inherited Members

Constructors

RationalValue(double, double)

Initializes a new instance of the RationalValue struct.

public RationalValue(double numerator, double denominator)

Parameters

numerator double

The numerator.

denominator double

The denominator.

RationalValue(NumberValue, NumberValue)

Initializes a new instance of the RationalValue struct.

public RationalValue(NumberValue numerator, NumberValue denominator)

Parameters

numerator NumberValue

The numerator.

denominator NumberValue

The denominator.

Properties

Denominator

Gets the denominator.

public NumberValue Denominator { get; }

Property Value

NumberValue

Numerator

Gets the numerator.

public NumberValue Numerator { get; }

Property Value

NumberValue

Methods

Abs(RationalValue)

Returns the absolute value of a rational number.

public static RationalValue Abs(RationalValue rationalValue)

Parameters

rationalValue RationalValue

The rational number.

Returns

RationalValue

The abs of rational number.

CompareTo(object?)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(object? obj)

Parameters

obj object

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes obj in the sort order.
Zero This instance occurs in the same position in the sort order as obj.
Greater than zero This instance follows obj in the sort order.

Exceptions

ArgumentException

obj is not the same type as this instance.

CompareTo(RationalValue)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(RationalValue other)

Parameters

other RationalValue

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Equals(RationalValue)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(RationalValue other)

Parameters

other RationalValue

An object to compare with this object.

Returns

bool

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

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Lb(RationalValue)

Returns the base 2 logarithm of a specified rational number.

public static NumberValue Lb(RationalValue rationalValue)

Parameters

rationalValue RationalValue

A rational number whose logarithm is to be found.

Returns

NumberValue

The binary logarithm.

Lg(RationalValue)

Returns the base 10 logarithm of a specified rational number.

public static NumberValue Lg(RationalValue rationalValue)

Parameters

rationalValue RationalValue

A rational number whose logarithm is to be found.

Returns

NumberValue

The base 10 logarithm.

Ln(RationalValue)

Returns the natural (base e) logarithm of a specified rational number.

public static NumberValue Ln(RationalValue rationalValue)

Parameters

rationalValue RationalValue

The rational number whose logarithm is to be found.

Returns

NumberValue

The natural (base e) logarithm.

Log(RationalValue, NumberValue)

Returns the logarithm of a specified number in a specified base.

public static NumberValue Log(RationalValue rationalValue, NumberValue @base)

Parameters

rationalValue RationalValue

The rational number whose logarithm is to be found.

base NumberValue

The base of the logarithm.

Returns

NumberValue

The logarithm.

Pow(RationalValue, NumberValue)

Returns the rational number raised to the specified power.

public static RationalValue Pow(RationalValue rationalValue, NumberValue numberValue)

Parameters

rationalValue RationalValue

The rational number.

numberValue NumberValue

The power.

Returns

RationalValue

The rationalValue raised to the numberValue.

ToCanonical()

Converts the current rational number to the canonical form.

public RationalValue ToCanonical()

Returns

RationalValue

The rational number in the canonical form.

ToIrrational()

Converts the current rational number to irrational.

public NumberValue ToIrrational()

Returns

NumberValue

The irrational number.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator +(NumberValue, RationalValue)

public static RationalValue operator +(NumberValue left, RationalValue right)

Parameters

left NumberValue

The first object to add.

right RationalValue

The second object to add.

Returns

RationalValue

An object that is the sum of left and right.

operator +(RationalValue, NumberValue)

public static RationalValue operator +(RationalValue left, NumberValue right)

Parameters

left RationalValue

The first object to add.

right NumberValue

The second object to add.

Returns

RationalValue

An object that is the sum of left and right.

operator +(RationalValue, RationalValue)

Adds two objects of RationalValue.

public static RationalValue operator +(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to add.

right RationalValue

The second object to add.

Returns

RationalValue

An object that is the sum of left and right.

operator /(NumberValue, RationalValue)

Divides double and RationalValue.

public static RationalValue operator /(NumberValue left, RationalValue right)

Parameters

left NumberValue

The first object to divide.

right RationalValue

The second object to divide.

Returns

RationalValue

An object that is the fraction of left and right.

operator /(RationalValue, NumberValue)

Divides RationalValue and double.

public static RationalValue operator /(RationalValue left, NumberValue right)

Parameters

left RationalValue

The first object to divide.

right NumberValue

The second object to divide.

Returns

RationalValue

An object that is the fraction of left and right.

operator /(RationalValue, RationalValue)

Divides two objects of RationalValue.

public static RationalValue operator /(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to divide.

right RationalValue

The second object to divide.

Returns

RationalValue

An object that is the fraction of left and right.

operator ==(RationalValue, RationalValue)

Determines whether two specified instances of RationalValue are equal.

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

Parameters

left RationalValue

The first object to compare.

right RationalValue

The second object to compare.

Returns

bool

true if left is equal to right; otherwise, false.

operator >(RationalValue, RationalValue)

Indicates whether left parameter is greater than the right parameter.

public static bool operator >(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to compare.

right RationalValue

The second object to compare.

Returns

bool

true if the left parameter is greater than the right parameter; otherwise, false.

operator >=(RationalValue, RationalValue)

Indicates whether left parameter is greater than or equal to the right parameter.

public static bool operator >=(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to compare.

right RationalValue

The second object to compare.

Returns

bool

true if the left parameter is greater than or equal to the right parameter; otherwise, false.

operator !=(RationalValue, RationalValue)

Determines whether two specified instances of RationalValue are not equal.

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

Parameters

left RationalValue

The first object to compare.

right RationalValue

The second object to compare.

Returns

bool

true if left is not equal to right; otherwise, false.

operator <(RationalValue, RationalValue)

Indicates whether left parameter is less than the right parameter.

public static bool operator <(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to compare.

right RationalValue

The second object to compare.

Returns

bool

true if the left parameter is less than the right parameter; otherwise, false.

operator <=(RationalValue, RationalValue)

Indicates whether left parameter is less than or equal to the right parameter.

public static bool operator <=(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to compare.

right RationalValue

The second object to compare.

Returns

bool

true if the left parameter is less than or equal to the right parameter; otherwise, false.

operator *(NumberValue, RationalValue)

Multiplies double and RationalValue.

public static RationalValue operator *(NumberValue left, RationalValue right)

Parameters

left NumberValue

The first object to multiply.

right RationalValue

The second object to multiply.

Returns

RationalValue

An object that is the product of left and right.

operator *(RationalValue, NumberValue)

Multiplies RationalValue and double.

public static RationalValue operator *(RationalValue left, NumberValue right)

Parameters

left RationalValue

The first object to multiply.

right NumberValue

The second object to multiply.

Returns

RationalValue

An object that is the product of left and right.

operator *(RationalValue, RationalValue)

Multiplies two objects of RationalValue.

public static RationalValue operator *(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to multiply.

right RationalValue

The second object to multiply.

Returns

RationalValue

An object that is the product of left and right.

operator -(NumberValue, RationalValue)

Subtracts double and RationalValue.

public static RationalValue operator -(NumberValue left, RationalValue right)

Parameters

left NumberValue

The first object to sub.

right RationalValue

The second object to sub.

Returns

RationalValue

An object that is the difference of left and right.

operator -(RationalValue, NumberValue)

Subtracts RationalValue and double.

public static RationalValue operator -(RationalValue left, NumberValue right)

Parameters

left RationalValue

The first object to sub.

right NumberValue

The second object to sub.

Returns

RationalValue

An object that is the difference of left and right.

operator -(RationalValue, RationalValue)

Subtracts two objects of RationalValue.

public static RationalValue operator -(RationalValue left, RationalValue right)

Parameters

left RationalValue

The first object to sub.

right RationalValue

The second object to sub.

Returns

RationalValue

An object that is the difference of left and right.

operator -(RationalValue)

Produces the negative of RationalValue.

public static RationalValue operator -(RationalValue rationalValue)

Parameters

rationalValue RationalValue

The rational number.

Returns

RationalValue

The negative of rationalValue.