Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
d274125c
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d274125c
编写于
9月 14, 2020
作者:
A
Artem Zuikov
提交者:
GitHub
9月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix wide integer left shift + refactoring (#14697)
上级
3113aa6c
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
365 addition
and
313 deletion
+365
-313
base/common/throwError.h
base/common/throwError.h
+13
-0
base/common/types.h
base/common/types.h
+2
-8
base/common/wide_integer.h
base/common/wide_integer.h
+72
-62
base/common/wide_integer_impl.h
base/common/wide_integer_impl.h
+232
-243
base/common/wide_integer_to_string.h
base/common/wide_integer_to_string.h
+35
-0
src/IO/WriteHelpers.h
src/IO/WriteHelpers.h
+7
-0
tests/queries/0_stateless/01475_fix_bigint_shift.reference
tests/queries/0_stateless/01475_fix_bigint_shift.reference
+2
-0
tests/queries/0_stateless/01475_fix_bigint_shift.sql
tests/queries/0_stateless/01475_fix_bigint_shift.sql
+2
-0
未找到文件。
base/common/throwError.h
0 → 100644
浏览文件 @
d274125c
#pragma once
#include <stdexcept>
/// Throw DB::Exception-like exception before its definition.
/// DB::Exception derived from Poco::Exception derived from std::exception.
/// DB::Exception generally cought as Poco::Exception. std::exception generally has other catch blocks and could lead to other outcomes.
/// DB::Exception is not defined yet. It'd better to throw Poco::Exception but we do not want to include any big header here, even <string>.
/// So we throw some std::exception instead in the hope its catch block is the same as DB::Exception one.
template
<
typename
T
>
inline
void
throwError
(
const
T
&
err
)
{
throw
std
::
runtime_error
(
err
);
}
base/common/types.h
浏览文件 @
d274125c
...
...
@@ -23,8 +23,8 @@ using UInt64 = uint64_t;
using
Int128
=
__int128
;
using
wInt256
=
std
::
wide_
integer
<
256
,
signed
>
;
using
wUInt256
=
std
::
wide_
integer
<
256
,
unsigned
>
;
using
wInt256
=
wide
::
integer
<
256
,
signed
>
;
using
wUInt256
=
wide
::
integer
<
256
,
unsigned
>
;
static_assert
(
sizeof
(
wInt256
)
==
32
);
static_assert
(
sizeof
(
wUInt256
)
==
32
);
...
...
@@ -119,12 +119,6 @@ template <> struct is_big_int<wUInt256> { static constexpr bool value = true; };
template
<
typename
T
>
inline
constexpr
bool
is_big_int_v
=
is_big_int
<
T
>::
value
;
template
<
typename
T
>
inline
std
::
string
bigintToString
(
const
T
&
x
)
{
return
to_string
(
x
);
}
template
<
typename
To
,
typename
From
>
inline
To
bigint_cast
(
const
From
&
x
[[
maybe_unused
]])
{
...
...
base/common/wide_integer.h
浏览文件 @
d274125c
...
...
@@ -22,79 +22,87 @@
* without express or implied warranty.
*/
#include <climits> // CHAR_BIT
#include <cmath>
#include <cstdint>
#include <limits>
#include <type_traits>
#include <initializer_list>
namespace
std
namespace
wide
{
template
<
size_t
Bits
,
typename
Signed
>
class
wide_integer
;
class
integer
;
}
namespace
std
{
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
struct
common_type
<
wide
_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
;
struct
common_type
<
wide
::
integer
<
Bits
,
Signed
>
,
wide
::
integer
<
Bits2
,
Signed2
>>
;
template
<
size_t
Bits
,
typename
Signed
,
typename
Arithmetic
>
struct
common_type
<
wide
_
integer
<
Bits
,
Signed
>
,
Arithmetic
>
;
struct
common_type
<
wide
::
integer
<
Bits
,
Signed
>
,
Arithmetic
>
;
template
<
typename
Arithmetic
,
size_t
Bits
,
typename
Signed
>
struct
common_type
<
Arithmetic
,
wide_integer
<
Bits
,
Signed
>>
;
struct
common_type
<
Arithmetic
,
wide
::
integer
<
Bits
,
Signed
>>
;
}
namespace
wide
{
template
<
size_t
Bits
,
typename
Signed
>
class
wide_
integer
class
integer
{
public:
using
base_type
=
uint8_t
;
using
signed_base_type
=
int8_t
;
// ctors
wide_
integer
()
=
default
;
integer
()
=
default
;
template
<
typename
T
>
constexpr
wide_
integer
(
T
rhs
)
noexcept
;
constexpr
integer
(
T
rhs
)
noexcept
;
template
<
typename
T
>
constexpr
wide_
integer
(
std
::
initializer_list
<
T
>
il
)
noexcept
;
constexpr
integer
(
std
::
initializer_list
<
T
>
il
)
noexcept
;
// assignment
template
<
size_t
Bits2
,
typename
Signed2
>
constexpr
wide_integer
<
Bits
,
Signed
>
&
operator
=
(
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
&
operator
=
(
const
integer
<
Bits2
,
Signed2
>
&
rhs
)
noexcept
;
template
<
typename
Arithmetic
>
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
=
(
Arithmetic
rhs
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
&
operator
=
(
Arithmetic
rhs
)
noexcept
;
template
<
typename
Arithmetic
>
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
*=
(
const
Arithmetic
&
rhs
);
constexpr
integer
<
Bits
,
Signed
>
&
operator
*=
(
const
Arithmetic
&
rhs
);
template
<
typename
Arithmetic
>
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
/=
(
const
Arithmetic
&
rhs
);
constexpr
integer
<
Bits
,
Signed
>
&
operator
/=
(
const
Arithmetic
&
rhs
);
template
<
typename
Arithmetic
>
constexpr
wide_integer
<
Bits
,
Signed
>
&
operator
+=
(
const
Arithmetic
&
rhs
)
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
integer
<
Bits
,
Signed
>
&
operator
+=
(
const
Arithmetic
&
rhs
)
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
template
<
typename
Arithmetic
>
constexpr
wide_integer
<
Bits
,
Signed
>
&
operator
-=
(
const
Arithmetic
&
rhs
)
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
integer
<
Bits
,
Signed
>
&
operator
-=
(
const
Arithmetic
&
rhs
)
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
template
<
typename
Integral
>
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
%=
(
const
Integral
&
rhs
);
constexpr
integer
<
Bits
,
Signed
>
&
operator
%=
(
const
Integral
&
rhs
);
template
<
typename
Integral
>
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
&=
(
const
Integral
&
rhs
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
&
operator
&=
(
const
Integral
&
rhs
)
noexcept
;
template
<
typename
Integral
>
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
|=
(
const
Integral
&
rhs
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
&
operator
|=
(
const
Integral
&
rhs
)
noexcept
;
template
<
typename
Integral
>
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
^=
(
const
Integral
&
rhs
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
&
operator
^=
(
const
Integral
&
rhs
)
noexcept
;
constexpr
wide_integer
<
Bits
,
Signed
>
&
operator
<<=
(
int
n
)
;
constexpr
wide_
integer
<
Bits
,
Signed
>
&
operator
>>=
(
int
n
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
&
operator
<<=
(
int
n
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
&
operator
>>=
(
int
n
)
noexcept
;
constexpr
wide_integer
<
Bits
,
Signed
>
&
operator
++
()
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
wide_integer
<
Bits
,
Signed
>
operator
++
(
int
)
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
wide_integer
<
Bits
,
Signed
>
&
operator
--
()
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
wide_integer
<
Bits
,
Signed
>
operator
--
(
int
)
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
integer
<
Bits
,
Signed
>
&
operator
++
()
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
constexpr
integer
<
Bits
,
Signed
>
operator
++
(
int
)
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
constexpr
integer
<
Bits
,
Signed
>
&
operator
--
()
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
constexpr
integer
<
Bits
,
Signed
>
operator
--
(
int
)
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
// observers
...
...
@@ -114,10 +122,10 @@ public:
private:
template
<
size_t
Bits2
,
typename
Signed2
>
friend
class
wide_
integer
;
friend
class
integer
;
friend
class
numeric_limits
<
wide_
integer
<
Bits
,
signed
>>
;
friend
class
numeric_limits
<
wide_
integer
<
Bits
,
unsigned
>>
;
friend
class
std
::
numeric_limits
<
integer
<
Bits
,
signed
>>
;
friend
class
std
::
numeric_limits
<
integer
<
Bits
,
unsigned
>>
;
base_type
m_arr
[
_impl
::
arr_size
];
};
...
...
@@ -134,115 +142,117 @@ using __only_integer = typename std::enable_if<IntegralConcept<T>() && IntegralC
// Unary operators
template
<
size_t
Bits
,
typename
Signed
>
constexpr
wide_integer
<
Bits
,
Signed
>
operator
~
(
const
wide_
integer
<
Bits
,
Signed
>
&
lhs
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
operator
~
(
const
integer
<
Bits
,
Signed
>
&
lhs
)
noexcept
;
template
<
size_t
Bits
,
typename
Signed
>
constexpr
wide_integer
<
Bits
,
Signed
>
operator
-
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
)
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
integer
<
Bits
,
Signed
>
operator
-
(
const
integer
<
Bits
,
Signed
>
&
lhs
)
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
template
<
size_t
Bits
,
typename
Signed
>
constexpr
wide_integer
<
Bits
,
Signed
>
operator
+
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
)
noexcept
(
is_same
<
Signed
,
unsigned
>::
value
);
constexpr
integer
<
Bits
,
Signed
>
operator
+
(
const
integer
<
Bits
,
Signed
>
&
lhs
)
noexcept
(
std
::
is_same_v
<
Signed
,
unsigned
>
);
// Binary operators
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
*
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
*
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
std
::
common_type_t
<
Arithmetic
,
Arithmetic2
>
constexpr
operator
*
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
/
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
/
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
std
::
common_type_t
<
Arithmetic
,
Arithmetic2
>
constexpr
operator
/
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
+
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
+
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
std
::
common_type_t
<
Arithmetic
,
Arithmetic2
>
constexpr
operator
+
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
-
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
-
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
std
::
common_type_t
<
Arithmetic
,
Arithmetic2
>
constexpr
operator
-
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
%
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
%
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Integral
,
typename
Integral2
,
class
=
__only_integer
<
Integral
,
Integral2
>
>
std
::
common_type_t
<
Integral
,
Integral2
>
constexpr
operator
%
(
const
Integral
&
rhs
,
const
Integral2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
&
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
&
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Integral
,
typename
Integral2
,
class
=
__only_integer
<
Integral
,
Integral2
>
>
std
::
common_type_t
<
Integral
,
Integral2
>
constexpr
operator
&
(
const
Integral
&
rhs
,
const
Integral2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
|
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
|
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Integral
,
typename
Integral2
,
class
=
__only_integer
<
Integral
,
Integral2
>
>
std
::
common_type_t
<
Integral
,
Integral2
>
constexpr
operator
|
(
const
Integral
&
rhs
,
const
Integral2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
std
::
common_type_t
<
wide_integer
<
Bits
,
Signed
>
,
wide_
integer
<
Bits2
,
Signed2
>>
constexpr
operator
^
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
std
::
common_type_t
<
integer
<
Bits
,
Signed
>
,
integer
<
Bits2
,
Signed2
>>
constexpr
operator
^
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Integral
,
typename
Integral2
,
class
=
__only_integer
<
Integral
,
Integral2
>
>
std
::
common_type_t
<
Integral
,
Integral2
>
constexpr
operator
^
(
const
Integral
&
rhs
,
const
Integral2
&
lhs
);
// TODO: Integral
template
<
size_t
Bits
,
typename
Signed
>
constexpr
wide_integer
<
Bits
,
Signed
>
operator
<<
(
const
wide_
integer
<
Bits
,
Signed
>
&
lhs
,
int
n
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
operator
<<
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
int
n
)
noexcept
;
template
<
size_t
Bits
,
typename
Signed
>
constexpr
wide_integer
<
Bits
,
Signed
>
operator
>>
(
const
wide_
integer
<
Bits
,
Signed
>
&
lhs
,
int
n
)
noexcept
;
constexpr
integer
<
Bits
,
Signed
>
operator
>>
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
int
n
)
noexcept
;
template
<
size_t
Bits
,
typename
Signed
,
typename
Int
,
typename
=
std
::
enable_if_t
<!
std
::
is_same_v
<
Int
,
int
>
>>
constexpr
wide_integer
<
Bits
,
Signed
>
operator
<<
(
const
wide_
integer
<
Bits
,
Signed
>
&
lhs
,
Int
n
)
noexcept
constexpr
integer
<
Bits
,
Signed
>
operator
<<
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
Int
n
)
noexcept
{
return
lhs
<<
int
(
n
);
}
template
<
size_t
Bits
,
typename
Signed
,
typename
Int
,
typename
=
std
::
enable_if_t
<!
std
::
is_same_v
<
Int
,
int
>
>>
constexpr
wide_integer
<
Bits
,
Signed
>
operator
>>
(
const
wide_
integer
<
Bits
,
Signed
>
&
lhs
,
Int
n
)
noexcept
constexpr
integer
<
Bits
,
Signed
>
operator
>>
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
Int
n
)
noexcept
{
return
lhs
>>
int
(
n
);
}
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
constexpr
bool
operator
<
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
constexpr
bool
operator
<
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
constexpr
bool
operator
<
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
constexpr
bool
operator
>
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
constexpr
bool
operator
>
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
constexpr
bool
operator
>
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
constexpr
bool
operator
<=
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
constexpr
bool
operator
<=
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
constexpr
bool
operator
<=
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
constexpr
bool
operator
>=
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
constexpr
bool
operator
>=
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
constexpr
bool
operator
>=
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
constexpr
bool
operator
==
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
constexpr
bool
operator
==
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
constexpr
bool
operator
==
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
,
size_t
Bits2
,
typename
Signed2
>
constexpr
bool
operator
!=
(
const
wide_integer
<
Bits
,
Signed
>
&
lhs
,
const
wide_
integer
<
Bits2
,
Signed2
>
&
rhs
);
constexpr
bool
operator
!=
(
const
integer
<
Bits
,
Signed
>
&
lhs
,
const
integer
<
Bits2
,
Signed2
>
&
rhs
);
template
<
typename
Arithmetic
,
typename
Arithmetic2
,
class
=
__only_arithmetic
<
Arithmetic
,
Arithmetic2
>
>
constexpr
bool
operator
!=
(
const
Arithmetic
&
rhs
,
const
Arithmetic2
&
lhs
);
template
<
size_t
Bits
,
typename
Signed
>
std
::
string
to_string
(
const
wide_integer
<
Bits
,
Signed
>
&
n
);
}
namespace
std
{
template
<
size_t
Bits
,
typename
Signed
>
struct
hash
<
wide
_
integer
<
Bits
,
Signed
>>
;
struct
hash
<
wide
::
integer
<
Bits
,
Signed
>>
;
}
...
...
base/common/wide_integer_impl.h
浏览文件 @
d274125c
此差异已折叠。
点击以展开。
base/common/wide_integer_to_string.h
0 → 100644
浏览文件 @
d274125c
#pragma once
#include <string>
#include "wide_integer.h"
namespace
wide
{
template
<
size_t
Bits
,
typename
Signed
>
inline
std
::
string
to_string
(
const
integer
<
Bits
,
Signed
>
&
n
)
{
std
::
string
res
;
if
(
integer
<
Bits
,
Signed
>::
_impl
::
operator_eq
(
n
,
0U
))
return
"0"
;
integer
<
Bits
,
unsigned
>
t
;
bool
is_neg
=
integer
<
Bits
,
Signed
>::
_impl
::
is_negative
(
n
);
if
(
is_neg
)
t
=
integer
<
Bits
,
Signed
>::
_impl
::
operator_unary_minus
(
n
);
else
t
=
n
;
while
(
!
integer
<
Bits
,
unsigned
>::
_impl
::
operator_eq
(
t
,
0U
))
{
res
.
insert
(
res
.
begin
(),
'0'
+
char
(
integer
<
Bits
,
unsigned
>::
_impl
::
operator_percent
(
t
,
10U
)));
t
=
integer
<
Bits
,
unsigned
>::
_impl
::
operator_slash
(
t
,
10U
);
}
if
(
is_neg
)
res
.
insert
(
res
.
begin
(),
'-'
);
return
res
;
}
}
src/IO/WriteHelpers.h
浏览文件 @
d274125c
...
...
@@ -11,6 +11,7 @@
#include <common/LocalDateTime.h>
#include <common/find_symbols.h>
#include <common/StringRef.h>
#include <common/wide_integer_to_string.h>
#include <Core/DecimalFunctions.h>
#include <Core/Types.h>
...
...
@@ -42,6 +43,12 @@ namespace ErrorCodes
extern
const
int
ILLEGAL_TYPE_OF_ARGUMENT
;
}
template
<
typename
T
>
inline
std
::
string
bigintToString
(
const
T
&
x
)
{
return
to_string
(
x
);
}
/// Helper functions for formatted and binary output.
inline
void
writeChar
(
char
x
,
WriteBuffer
&
buf
)
...
...
tests/queries/0_stateless/01475_fix_bigint_shift.reference
0 → 100644
浏览文件 @
d274125c
-4
-4
tests/queries/0_stateless/01475_fix_bigint_shift.sql
0 → 100644
浏览文件 @
d274125c
SELECT
bitShiftLeft
(
toInt64
(
-
2
),
1
);
SELECT
bitShiftLeft
(
toInt256
(
-
2
),
1
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录