ClickHouse server version 20.8.9 revision 54438

Let's imagine some simple table structure:

```
CREATE TABLE users (
    `user_id` Int32
)
```

Modulo operator on **Int32** field with **150** argument returns negative result. This could have happened due to wrong type casting - result should be casted to **Int16** or **UInt8** instead of **Int8**.

```
SELECT 
    user_id % 150, 
    441746 % 150,
    toTypeName(user_id % 150),
    toTypeName(441746 % 150)
FROM users 
WHERE user_id = 441746
LIMIT 1
```

```
┌─modulo(user_id, 150)─┬─modulo(441746, 150)─┬─toTypeName(modulo(user_id, 150))─┬─toTypeName(modulo(441746, 150))─┐
│                -110  │                 146 │ Int8                             │ UInt8                           │
└──────────────────────┴─────────────────────┴──────────────────────────────────┴─────────────────────────────────┘
```
{
    using Type = typename Construct<
        true,
        std::is_floating_point_v<A>,
        is_signed_v<A> ? sizeof(A) : nextSize(sizeof(A))>::Type;
};
template <typename A> struct ResultOfAbs
{
    using Type = typename Construct<
        false,
        std::is_floating_point_v<A>,
        sizeof(A)>::Type;
};
/** For bitwise operations, an integer is obtained with number of bits is equal to the maximum of the arguments.
    */
template <typename A, typename B> struct ResultOfBit
{
    using Type = typename Construct<
        is_signed_v<A> || is_signed_v<B>,
        false,
        std::is_floating_point_v<A> || std::is_floating_point_v<B> ? 8 : max(sizeof(A), sizeof(B))>::Type;
};
template <typename A> struct ResultOfBitNot
{
    using Type = typename Construct<
        is_signed_v<A>,
        false,
        sizeof(A)>::Type;
};
/** Type casting for `if` function: