# How to divide different uint/int types after Solidity 0.8.0

**URL:** <https://forum.openzeppelin.com/t/how-to-divide-different-uint-int-types-after-solidity-0-8-0/18117>\
**Category:** Smart Contracts\
**Created:** [November 3, 2021, 7:21am UTC](https://forum.openzeppelin.com/t/how-to-divide-different-uint-int-types-after-solidity-0-8-0/18117 "2021-11-03T07:21:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TtheBC01](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/tthebc01/32/14174_2.png) [@TtheBC01](https://forum.openzeppelin.com/u/TtheBC01)\
**Post date:** [November 3, 2021, 7:21am UTC](https://forum.openzeppelin.com/t/how-to-divide-different-uint-int-types-after-solidity-0-8-0/18117/1 "2021-11-03T07:21:59Z")

</div>

I was trying out the Uniswap's [Oracle library](https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/OracleLibrary.sol) to interact with the price feed that their token pools expose. I noticed that if I try to use a solidity compiler greater than `0.8.0`, I get the compiler error:

```auto
TypeError: Operator / not compatible with types int56 and uint32
  --> contracts/OracleTest.sol:31:42:
   |
31 | timeWeightedAverageTick = int24( tickCumulativesDelta / period );
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

```

The function I'm trying to compile is straight from the Uniswap npm package:

```auto
    function consult(address pool, uint32 period) internal view returns (int24 timeWeightedAverageTick) {
        require(period != 0, 'BP');

        uint32[] memory secondAgos = new uint32[](2);
        secondAgos[0] = period;
        secondAgos[1] = 0;

        (int56[] memory tickCumulatives, ) = IUniswapV3Pool(pool).observe(secondAgos);
        int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0];

        timeWeightedAverageTick = int24( tickCumulativesDelta / period );

        // Always round to negative infinity
        if (tickCumulativesDelta < 0 && (tickCumulativesDelta % period != 0)) timeWeightedAverageTick--;
    }

```

I know that solidity `0.8` changed some things regarding implicit type conversion and overflow protection, so probably that is what is causing the compile-time errors. I tried some throwing an `unchecked` block in but still get implicit type conversion errors.

Has anyone come across this problem already and found a good work around besides just rolling back to `0.7`?

---

<div class="post-metadata">

**Author:** ![aiwowo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/aiwowo/32/11445_2.png) [@aiwowo](https://forum.openzeppelin.com/u/aiwowo)\
**Post date:** [December 17, 2021, 6:22am UTC](https://forum.openzeppelin.com/t/how-to-divide-different-uint-int-types-after-solidity-0-8-0/18117/2 "2021-12-17T06:22:42Z")

</div>

The solution is :  
timeWeightedAverageTick = int24( tickCumulativesDelta / int56( int32(period) ) );

basically you need to first convert the unsigned to signed integer with the same kind in either same width or same type. e.g.: `uint16(uint8(int8))` or `uint16(int16(int8))` .

The details can be found in the solidity 0.8.0 breaking change doc. [https://docs.soliditylang.org/en/v0.8.10/080-breaking-changes.html](https://docs.soliditylang.org/en/v0.8.10/080-breaking-changes.html)
