Rational

A compile-time rational number.

If you explicitely specify the denominator, be sure to use an *unsigned* integer literal (e.g. 2u) – even though the template accepts only unsigned integers anyway, this seems to make a difference.

Note: This was tailored to the specific needs of the units library, and isn't optimized at all.

Members

Aliases

Rational
alias Rational = Rational!(n / cast(int)gcd_, d / gcd_)
Undocumented in source.

Manifest constants

gcd_
enum gcd_;
Undocumented in source.

Structs

Rational
struct Rational
Undocumented in source.

Examples

static assert(is(Rational!(2, 1u) == Rational!2));
static assert(is(Rational!(6, 3u) == Rational!2));

Meta