Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wa-lang
wa
提交
9c615cf0
wa
项目概览
wa-lang
/
wa
大约 1 年 前同步成功
通知
68
Star
655
Fork
45
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
wa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9c615cf0
编写于
8月 05, 2023
作者:
chai2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
math/bits 补充测试
上级
dd68b064
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
85 addition
and
0 deletion
+85
-0
waroot/src/math/bits/example_test.wa
waroot/src/math/bits/example_test.wa
+85
-0
未找到文件。
waroot/src/math/bits/example_test.wa
0 → 100644
浏览文件 @
9c615cf0
// 版权 @2023 凹语言 作者。保留所有权利。
func ExampleLeadingZeros8 {
assert(0b00000001 == 1)
println("LeadingZeros8(00000001) =", LeadingZeros8(1))
// Output:
// LeadingZeros8(00000001) = 7
}
func ExampleLeadingZeros16 {
assert(0b0000000000000001 == 1)
println("LeadingZeros16(0000000000000001) =", LeadingZeros16(1))
// Output:
// LeadingZeros16(0000000000000001) = 15
}
func ExampleLeadingZeros32 {
assert(0b00000000000000000000000000000001 == 1)
println("LeadingZeros32(00000000000000000000000000000001) =", LeadingZeros32(1))
// Output:
// LeadingZeros32(00000000000000000000000000000001) = 31
}
func ExampleLeadingZeros64 {
assert(0b0000000000000000000000000000000000000000000000000000000000000001 == 1)
println("LeadingZeros64(0000000000000000000000000000000000000000000000000000000000000001) =", LeadingZeros64(1))
// Output:
// LeadingZeros64(0000000000000000000000000000000000000000000000000000000000000001) = 63
}
func ExampleTrailingZeros8 {
assert(0b00001110 == 14)
println("TrailingZeros8(00001110) =", TrailingZeros8(14))
// Output:
// TrailingZeros8(00001110) = 1
}
func ExampleTrailingZeros16 {
assert(0b0000000000001110 == 14)
println("TrailingZeros16(0000000000001110) =", TrailingZeros16(14))
// Output:
// TrailingZeros16(0000000000001110) = 1
}
func ExampleTrailingZeros32 {
assert(0b00000000000000000000000000001110 == 14)
println("TrailingZeros32(00000000000000000000000000001110) =", TrailingZeros32(14))
// Output:
// TrailingZeros32(00000000000000000000000000001110) = 1
}
func ExampleTrailingZeros64 {
assert(0b0000000000000000000000000000000000000000000000000000000000001110 == 14)
println("TrailingZeros64(0000000000000000000000000000000000000000000000000000000000001110) =", TrailingZeros64(14))
// Output:
// TrailingZeros64(0000000000000000000000000000000000000000000000000000000000001110) = 1
}
func ExampleOnesCount8 {
assert(0b00001110 == 14)
println("OnesCount8(00001110) =", OnesCount8(14))
// Output:
// OnesCount8(00001110) = 3
}
func ExampleOnesCount16 {
assert(0b0000000000001110 == 14)
println("OnesCount16(0000000000001110) =", OnesCount16(14))
// Output:
// OnesCount16(0000000000001110) = 3
}
func ExampleOnesCount32 {
assert(0b00000000000000000000000000001110 == 14)
println("OnesCount32(00000000000000000000000000001110) =", OnesCount32(14))
// Output:
// OnesCount32(00000000000000000000000000001110) = 3
}
func ExampleOnesCount64 {
assert(0b0000000000000000000000000000000000000000000000000000000000001110 == 14)
println("OnesCount64(0000000000000000000000000000000000000000000000000000000000001110) =", OnesCount64(14))
// Output:
// OnesCount64(0000000000000000000000000000000000000000000000000000000000001110) = 3
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录