library UQ112x112 {
    uint224 constant Q112 = 2**112;

    // Encode a uint112 as a UQ112x112
    function encode(uint112 y) internal pure returns (uint224 z) {
        z = uint224(y) * Q112; // never overflows
    }

    // Multiply a UQ112x112 by a uint112, returning a UQ112x112
    function uqmul(uint224 x, uint112 y) internal pure returns (uint224 z) {
        z = x * uint224(y);
    }

    // Divide a UQ112x112 by a uint112, returning a UQ112x112
    function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
        z = x / uint224(y);
    }
}
/**
 * A library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
 * range: [0, 2**112 - 1]
 * resolution: 1 / 2**112
 */
function uqmul(uint224 x, uint112 y) internal pure returns (uint224 z) {
    z = x * uint224(y);
}

// Multiply a UQ112x112 by a uint112, returning a UQ112x112