Table of Contents

Struct Rational

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

Represents a rational number.

public struct Rational : IEquatable<Rational>
Implements
Extension Methods

Remarks

The Rational structure operates under the following rules:

  • 0/0 is legal and will be interpreted as 0/1.
  • 0/anything is interpreted as zero.
  • If you are representing a whole number, the denominator should be 1.

Constructors

Rational(int, int)

Represents a rational number.

public Rational(int numerator, int denominator)

Parameters

numerator int

The numerator (top) of the rational number.

denominator int

The denominator (bottom) of the rational number.

Remarks

The Rational structure operates under the following rules:

  • 0/0 is legal and will be interpreted as 0/1.
  • 0/anything is interpreted as zero.
  • If you are representing a whole number, the denominator should be 1.

Fields

Denominator

An value representing the bottom of the rational number.

public int Denominator

Field Value

int

Numerator

An value representing the top of the rational number.

public int Numerator

Field Value

int

Methods

Equals(Rational)

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

public readonly bool Equals(Rational other)

Parameters

other Rational

An object to compare with this object.

Returns

bool

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

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly 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.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

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

ToString()

Returns the string representation of this Rational, including its approximate real value.

public override string ToString()

Returns

string

The string representation of this Rational.

Operators

operator ==(Rational, Rational)

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

Parameters

left Rational
right Rational

Returns

bool

implicit operator Rational(int)

Returns a new Rational from an integer value.

public static implicit operator Rational(int value)

Parameters

value int

The integer value.

Returns

Rational

The integer value as a rational number with denominator 1.

operator !=(Rational, Rational)

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

Parameters

left Rational
right Rational

Returns

bool