aboutsummaryrefslogtreecommitdiff
path: root/test/integers.tm
blob: 556835001df65853258eac553d7d4003cf6bb2cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
func main():
	>> 2 + 3
	= 5

	>> 2 * 3
	= 6

	>> 2 + 3 * 4
	= 14

	>> 2 * 3 + 4
	= 10

	>> 1i8 + 2i16
	= 3_i16

	>> 1 << 10
	= 1024

	>> 3 and 2
	= 2

	>> 3 or 4
	= 7

	>> 3 xor 2
	= 1

	nums := ""
	for x in 5:
		nums ++= "{x},"
	>> nums
	= "1,2,3,4,5,"

	>> x := 123i64
	>> x:format(digits=5)
	= "00123"
	>> x:hex()
	= "0x7B"
	>> x:octal()
	= "0o173"

	>> Int.random(1, 100)
	>> Int64.min
	= -9223372036854775808
	>> Int64.max
	= 9223372036854775807


	>> 123_i32:hex()
	= "0x7B"
	>> 123_i16:hex()
	= "0x7B"
	>> 123_i8:hex()
	= "0x7B"

	>> Int(2.1)
	= 2 : Int

	do:
		>> small_int := 1
		= 1
		>> max_small_int := 536870911
		= 536870911
		>> max_i64 := 536870912
		= 536870912
		>> super_big := 9999999999999999999999
		= 9999999999999999999999
		>> max_small_int + 1
		= 536870912

		>> max_small_int + max_small_int
		= 1073741822

		>> super_big + 1
		= 10000000000000000000000