RationalMath
library RationalMath
Source: rationals/RationalMath.sol
Reference
Functions
div
function div(Rational.Rational256 a, Rational.Rational256 b) internal pure returns (Rational.Rational256)
- Parameters:
a
- Rational.Rational256b
- Rational.Rational256- Returns:
- Rational.Rational256
gt
function gt(Rational.Rational256 r1, Rational.Rational256 r2) internal pure returns (bool)
- Parameters:
r1
- Rational.Rational256r2
- Rational.Rational256- Returns:
- bool
gte
function gte(Rational.Rational256 r1, Rational.Rational256 r2) internal pure returns (bool)
- Parameters:
r1
- Rational.Rational256r2
- Rational.Rational256- Returns:
- bool
lt
function lt(Rational.Rational256 r1, Rational.Rational256 r2) internal pure returns (bool)
- Parameters:
r1
- Rational.Rational256r2
- Rational.Rational256- Returns:
- bool
lte
function lte(Rational.Rational256 r1, Rational.Rational256 r2) internal pure returns (bool)
- Parameters:
r1
- Rational.Rational256r2
- Rational.Rational256- Returns:
- bool
mul
function mul(Rational.Rational256 a, Rational.Rational256 b) internal pure returns (Rational.Rational256)
- Parameters:
a
- Rational.Rational256b
- Rational.Rational256- Returns:
- Rational.Rational256
mul
function mul(Rational.Rational256 r, uint256 u) internal pure returns (Rational.Rational256)
Multiplies Rational and uint.
- Parameters:
r
- Rational.Rational256u
- uint256- Returns:
- Product as a Rational
reciprocal
function reciprocal(Rational.Rational256 r) internal pure returns (Rational.Rational256)
- Parameters:
r
- Rational.Rational256- Returns:
- Rational.Rational256
scalarMul
function scalarMul(Rational.Rational256 r, uint256 u) internal pure returns (uint256)
Multiplies Rational and uint.
- Parameters:
r
- Rational.Rational256u
- uint256- Returns:
- Product as a uint
toUInt256
function toUInt256(Rational.Rational256 r) internal pure returns (uint256)
Converts rational to uint256. Warning: may be rounding error.
- Parameters:
r
- Rational.Rational256- Returns:
- uint256