Import std.math.big.rational
std.math.big.rational
Rational: a fraction of two BigInts, which never changes once it's made, kept in lowest terms with its denominator above 0, so its arithmetic is exact: 1/3 + 1/6 is 1/2. An Int64 on either side of an operator works too.
std/math/big/rational.fb
Types
Rational
class
Public Class Rational Implements Comparable, Hashable, Printable, Numeric
A fraction of two BigInts, in lowest terms, which is exact however it's added and multiplied.
std/math/big/rational.fb, line 17
-
Its numerator, which has its sign.
-
Its denominator, which is above 0.
-
The fraction in lowest terms, with its denominator above 0, so Rational(2, -4) is -1/2. A
denominatorof 0 panics. -
The fraction
numeratoroverdenominator, in lowest terms. A denominator of 0 panics. -
The BigInt, over 1.
-
The number that adding leaves alone: 0.
Doc from
std.core.interfaces.Numeric.Zero. -
The number that multiplying leaves alone: 1.
Doc from
std.core.interfaces.Numeric.One. -
The Double exactly, as a fraction over a power of 2, so 0.1 is 3602879701896397/36028797018963968. A NaN or an infinity panics.
-
The Decimal exactly, as 0.75 is 3/4: its digits times or over a power of 10, from its text, as "-1.25E-7" and "0.75" are, so 1E+999999 doesn't go through a million digits.
-
The fraction the
textis: an integer, a "/", and digits, as "-3/4" is, or a Decimal'stext, as "0.75" and "1e-3" are. Other text is Null, and so is a denominator of 0. -
"3/4", or only the numerator when the denominator is 1, as in "-5".
-
The Double nearest it, ties to even: an infinity past the largest Double, and 0 below the smallest.
-
It as a Decimal, in a Decimal's 28 digits.
-
-1, 0, or 1 as it's below, at, or above 0.
-
Its distance from 0: the same fraction, without its sign.
-
The whole number it rounds to: toward 0, down, up, or to the nearest, a half to the even one.
-
The whole number it rounds down to.
-
The whole number it rounds up to.
-
The whole number nearest it, a half to the even one.
-
Its hash, the same for values that are equal.
Doc from
std.core.interfaces.Hashable.Hash. -
Whether
aandbare equal.Doc from
std.core.interfaces.Equatable.Operator==. -
Whether
aandbare equal. -
Whether
aandbare equal. -
Whether
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<. -
Whether
acomes beforeb. -
Whether
acomes beforeb. -
Whether
acomes afterb. -
Whether
acomes afterb. -
Whether
acomes beforebor is equal to it. -
Whether
acomes beforebor is equal to it. -
Whether
acomes afterbor is equal to it. -
Whether
acomes afterbor is equal to it. -
aandbadded up.Doc from
std.core.interfaces.Numeric.Operator+. -
aplusb. -
aplusb. -
btaken away froma.Doc from
std.core.interfaces.Numeric.Operator-. -
aminusb. -
aminusb. -
aandbmultiplied together.Doc from
std.core.interfaces.Numeric.Operator*. -
atimesb. -
atimesb. -
adivided byb.Doc from
std.core.interfaces.Numeric.Operator/. -
adivided byb. -
adivided byb. -
To a whole power, which can be below 0, as 2/3 to -2 is 9/4. Anything to 0 is 1, and 0 to a power below 0 panics.
-
anegated.
Report an issue with this page or with FutureBlitz on GitHub.