make clear that this is still just a mock

This commit is contained in:
Noah Zinsmeister
2019-11-21 18:35:02 -05:00
parent fe96d9a789
commit 410ca57f55
2 changed files with 5 additions and 18 deletions

View File

@ -1,17 +1,16 @@
pragma solidity 0.5.12;
// TODO this whole library is basically just a mock at the moment
// TODO this library is broken at the moment, and is meant only to serve as a mock
library UQ104x104 {
uint208 constant Q104 = uint104(-1);
function encode(uint128 y) internal pure returns (uint208 z) {
// require(y <= Q104, "encode-overflow");
require(y <= Q104, "encode-overflow");
z = y * Q104;
}
function qmul(uint208 x, uint208 y) internal pure returns (uint208 z) {
z = x * y / Q104;
}
function qdiv(uint208 x, uint208 y) internal pure returns (uint208 z) {
z = x / y;
uint256 quotient = uint256(x) / uint256(y);
require(quotient <= Q104, "div-overflow");
z = uint208(quotient * Q104);
}
}