Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
7a29d484
提交
7a29d484
authored
11月 12, 2017
作者:
LaughingMan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove nextPowerOf2(long) since it is now unused.
上级
952c39e1
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
0 行增加
和
39 行删除
+0
-39
MathUtils.java
h2/src/main/org/h2/util/MathUtils.java
+0
-25
TestMathUtils.java
h2/src/test/org/h2/test/unit/TestMathUtils.java
+0
-14
没有找到文件。
h2/src/main/org/h2/util/MathUtils.java
浏览文件 @
7a29d484
...
...
@@ -236,31 +236,6 @@ public class MathUtils {
return
++
x
;
}
/**
* Get the value that is equal to or higher than this value, and that is a
* power of two.
*
* @param x the original value
* @return the next power of two value
* @throws IllegalArgumentException if x < 0 or x > 0x4000000000000000
*/
public
static
long
nextPowerOf2
(
long
x
)
throws
IllegalArgumentException
{
if
(
x
==
0
)
{
return
1
;
}
else
if
(
x
<
0
||
x
>
0x4000000000000000
L
)
{
throw
new
IllegalArgumentException
(
"Argument out of range"
+
" [0x0-0x4000000000000000]. Argument was: "
+
x
);
}
x
--;
x
|=
x
>>
1
;
x
|=
x
>>
2
;
x
|=
x
>>
4
;
x
|=
x
>>
8
;
x
|=
x
>>
16
;
x
|=
x
>>
32
;
return
++
x
;
}
/**
* Convert a long value to an int value. Values larger than the biggest int
* value is converted to the biggest int value, and values smaller than the
...
...
h2/src/test/org/h2/test/unit/TestMathUtils.java
浏览文件 @
7a29d484
...
...
@@ -26,7 +26,6 @@ public class TestMathUtils extends TestBase {
public
void
test
()
{
testRandom
();
testNextPowerOf2Int
();
testNextPowerOf2Long
();
}
private
void
testRandom
()
{
...
...
@@ -63,17 +62,4 @@ public class TestMathUtils extends TestBase {
}
}
private
void
testNextPowerOf2Long
()
{
// the largest power of two that fits into a long
final
long
LARGEST_POW2
=
0x4000000000000000
L
;
long
[]
testValues
=
{
0
,
1
,
2
,
3
,
4
,
12
,
17
,
500
,
1023
,
LARGEST_POW2
-
500
,
LARGEST_POW2
};
long
[]
resultValues
=
{
1
,
1
,
2
,
4
,
4
,
16
,
32
,
512
,
1024
,
LARGEST_POW2
,
LARGEST_POW2
};
for
(
int
i
=
0
;
i
<
testValues
.
length
;
i
++)
{
assertEquals
(
resultValues
[
i
],
MathUtils
.
nextPowerOf2
(
testValues
[
i
]));
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论