Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
75357ab9
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,发现更多精彩内容 >>
提交
75357ab9
编写于
6月 22, 2020
作者:
A
Alexey Milovidov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
constexpr intExp10
上级
b136999f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
67 deletion
+70
-67
src/Common/intExp.h
src/Common/intExp.h
+70
-67
未找到文件。
src/Common/intExp.h
浏览文件 @
75357ab9
...
...
@@ -20,14 +20,14 @@ inline NO_SANITIZE_UNDEFINED uint64_t intExp2(int x)
return
1ULL
<<
x
;
}
inline
uint64_t
intExp10
(
int
x
)
constexpr
inline
uint64_t
intExp10
(
int
x
)
{
if
(
x
<
0
)
return
0
;
if
(
x
>
19
)
return
std
::
numeric_limits
<
uint64_t
>::
max
();
static
const
uint64_t
table
[
20
]
=
constexpr
uint64_t
table
[
20
]
=
{
1ULL
,
10ULL
,
100ULL
,
1000ULL
,
10000ULL
,
100000ULL
,
...
...
@@ -44,9 +44,10 @@ inline uint64_t intExp10(int x)
namespace
common
{
inline
int
exp10_i32
(
int
x
)
constexpr
inline
int
exp10_i32
(
int
x
)
{
static
const
int
values
[]
=
{
constexpr
int
values
[]
=
{
1
,
10
,
100
,
...
...
@@ -61,74 +62,76 @@ inline int exp10_i32(int x)
return
values
[
x
];
}
inline
int64_t
exp10_i64
(
int
x
)
constexpr
inline
int64_t
exp10_i64
(
int
x
)
{
static
const
int64_t
values
[]
=
{
1ll
,
10ll
,
100ll
,
1000ll
,
10000ll
,
100000ll
,
1000000ll
,
10000000ll
,
100000000ll
,
1000000000ll
,
10000000000ll
,
100000000000ll
,
1000000000000ll
,
10000000000000ll
,
100000000000000ll
,
1000000000000000ll
,
10000000000000000ll
,
100000000000000000ll
,
1000000000000000000ll
constexpr
int64_t
values
[]
=
{
1LL
,
10LL
,
100LL
,
1000LL
,
10000LL
,
100000LL
,
1000000LL
,
10000000LL
,
100000000LL
,
1000000000LL
,
10000000000LL
,
100000000000LL
,
1000000000000LL
,
10000000000000LL
,
100000000000000LL
,
1000000000000000LL
,
10000000000000000LL
,
100000000000000000LL
,
1000000000000000000LL
};
return
values
[
x
];
}
inline
__int128
exp10_i128
(
int
x
)
constexpr
inline
__int128
exp10_i128
(
int
x
)
{
static
const
__int128
values
[]
=
{
static_cast
<
__int128
>
(
1ll
),
static_cast
<
__int128
>
(
10ll
),
static_cast
<
__int128
>
(
100ll
),
static_cast
<
__int128
>
(
1000ll
),
static_cast
<
__int128
>
(
10000ll
),
static_cast
<
__int128
>
(
100000ll
),
static_cast
<
__int128
>
(
1000000ll
),
static_cast
<
__int128
>
(
10000000ll
),
static_cast
<
__int128
>
(
100000000ll
),
static_cast
<
__int128
>
(
1000000000ll
),
static_cast
<
__int128
>
(
10000000000ll
),
static_cast
<
__int128
>
(
100000000000ll
),
static_cast
<
__int128
>
(
1000000000000ll
),
static_cast
<
__int128
>
(
10000000000000ll
),
static_cast
<
__int128
>
(
100000000000000ll
),
static_cast
<
__int128
>
(
1000000000000000ll
),
static_cast
<
__int128
>
(
10000000000000000ll
),
static_cast
<
__int128
>
(
100000000000000000ll
),
static_cast
<
__int128
>
(
1000000000000000000ll
),
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
10ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
1000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
10000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
1000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
10000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
1000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
10000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
1000000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
10000000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
1000000000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
10000000000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000000000000000ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000000000000000ll
*
10ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000000000000000ll
*
100ll
,
static_cast
<
__int128
>
(
1000000000000000000ll
)
*
100000000000000000ll
*
1000ll
constexpr
__int128
values
[]
=
{
static_cast
<
__int128
>
(
1LL
),
static_cast
<
__int128
>
(
10LL
),
static_cast
<
__int128
>
(
100LL
),
static_cast
<
__int128
>
(
1000LL
),
static_cast
<
__int128
>
(
10000LL
),
static_cast
<
__int128
>
(
100000LL
),
static_cast
<
__int128
>
(
1000000LL
),
static_cast
<
__int128
>
(
10000000LL
),
static_cast
<
__int128
>
(
100000000LL
),
static_cast
<
__int128
>
(
1000000000LL
),
static_cast
<
__int128
>
(
10000000000LL
),
static_cast
<
__int128
>
(
100000000000LL
),
static_cast
<
__int128
>
(
1000000000000LL
),
static_cast
<
__int128
>
(
10000000000000LL
),
static_cast
<
__int128
>
(
100000000000000LL
),
static_cast
<
__int128
>
(
1000000000000000LL
),
static_cast
<
__int128
>
(
10000000000000000LL
),
static_cast
<
__int128
>
(
100000000000000000LL
),
static_cast
<
__int128
>
(
1000000000000000000LL
),
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
10LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
1000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
10000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
1000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
10000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
1000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
10000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
1000000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
10000000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
1000000000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
10000000000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000000000000000LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000000000000000LL
*
10LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000000000000000LL
*
100LL
,
static_cast
<
__int128
>
(
1000000000000000000LL
)
*
100000000000000000LL
*
1000LL
};
return
values
[
x
];
}
...
...
@@ -138,7 +141,7 @@ inline __int128 exp10_i128(int x)
/// intExp10 returning the type T.
template
<
typename
T
>
inline
T
intExp10OfSize
(
int
x
)
constexpr
inline
T
intExp10OfSize
(
int
x
)
{
if
constexpr
(
sizeof
(
T
)
<=
8
)
return
intExp10
(
x
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录