Rational

The struct that implements rational numbers. All relevant operators (addition, subtraction, multiplication, division, exponentiation by a non-negative integer, equality and comparison) are overloaded. The second operand for all binary operators except exponentiation may be either another Rational or another integer type.

Members

Functions

inverse
typeof(this) inverse()

//////////////////////////////////////////////////////////////////////////// Get inverse.

invert
void invert()

Invert this.

opAssign
typeof(this) opAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opAssign
typeof(this) opAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Rational!(SomeIntegral) opBinary(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Rational!(SomeIntegral) opBinary(Rhs that)

ditto

opBinary
typeof(this) opBinary(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
typeof(this) opBinary(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
auto opBinary(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
auto opBinary(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
auto opBinary(Rhs that)

ditto

opBinaryRight
auto opBinaryRight(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
typeof(this) opBinaryRight(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
auto opBinaryRight(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
typeof(this) opBinaryRight(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
F opCast()

Convert to floating point representation.

opCast
I opCast()

Casts this to an integer by truncating the fractional part. Equivalent to integerPart, and then casting it to type I.

opCmp
int opCmp(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)

ditto

opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
typeof(this) opOpAssign(Rhs that)
Undocumented in source. Be warned that the author may not have intended to support it.
opUnary
typeof(this) opUnary()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()

Returns a string representation of this in the form a/b.

Imports

isAssignable (from std.traits)
public import std.traits : isAssignable;
Undocumented in source.
isFloatingPoint (from std.traits)
public import std.traits : isFloatingPoint;
Undocumented in source.

Properties

denominator
inout(SomeIntegral) denominator [@property getter]

Returns the denominator.

fractionPart
typeof(this) fractionPart [@property getter]

Returns the fractional part of this rational.

integerPart
SomeIntegral integerPart [@property getter]

Returns the integer part of this rational, with any remainder truncated.

numerator
inout(SomeIntegral) numerator [@property getter]

Returns the numerator.

Meta