ClickHouse / ClickHouse/ClickHouse

modulo operation, unexpected result: -2574499495101583472 % 10::UInt64 != -2574499495101583472 % 10::Int64

Open
#52,031 4 comments 0 reactions 0 assignees View on GitHub
comp-regular-function external unexpected behaviour
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

**Describe the unexpected behaviour**
A clear and concise description of what works not as it is supposed to.

**How to reproduce**

```
SELECT
-2574499495101583472 AS key,
key % CAST('10', 'UInt32') AS uint32,
key % CAST('10', 'UInt64') AS uint64,
key % CAST('10', 'Int64') AS int64,
toTypeName(uint32) AS type_uint32,
toTypeName(uint64) AS type_uint64,
toTypeName(int64) AS type_int64

Query id: f0cb79d0-c464-436a-98ce-5dc7b0224a91

┌──────────────────key─┬─uint32─┬─uint64─┬─int64─┬─type_uint32─┬─type_uint64─┬─type_int64─┐
│ -2574499495101583472 │ -2 │ 4 │ -2 │ Int64 │ Int64 │ Int64 │
└──────────────────────┴────────┴────────┴───────┴─────────────┴─────────────┴────────────┘
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.