check.bend

bend-osdev-word64@0.1.0.0 · 26 lines · 0 definitions

1import Base
2import bend-osdev-word64@0.1.0.0/word64.bend as W
3
4# 10^12 = 0xE8_D4A51000
5def trillion() -> W.W64:
6  W.W64.from_parts(232, 3567587328)
7
8def main() -> IO(Unit):
9  do IO<Unit>:
10    IO.print(W.W64.show(W.W64.max()))
11    IO.print(W.W64.show_hex(W.W64.add(W.W64.max(), W.W64.one())))
12    IO.print(W.W64.show_hex(W.W64.mul(W.W64.from_u32(4294967295), W.W64.from_u32(4294967295))))
13    IO.print(W.W64.show_hex(W.W64.shl(W.W64.from_parts(3735928559, 3405691582), 8n)))
14    IO.print(U32.show(W.W64.hi(W.W64.from_parts(7, 9))))
15    IO.print(W.W64.show(W.W64.div(trillion(), W.W64.from_u32(7))))
16    IO.print(W.W64.show(W.W64.mod(trillion(), W.W64.from_u32(7))))
17    IO.print(Bool.show(W.W64.is_lt(W.W64.from_parts(1, 0), W.W64.from_parts(0, 4294967295))))
18
19#|18446744073709551615
20#|0000000000000000
21#|fffffffe00000001
22#|adbeefcafebabe00
23#|7
24#|142857142857
25#|1
26#|False