blob: 21557c6748111d13d53137b81a5f594d9060d0ec (
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
|
string :: []u8;
main :: () -> void {
str := "123";
print(str);
v := to_u64(str);
print(v);
};
print :: (value:[]u8)->void{
i :u64= 0;
while i < value.length {
putc value[i];
i += 1;
}
};
print :: (value:u64)->void{
value := value;
result :[20]u8 = undefined;
i := 0;
while {
result[i] = '0' + @cast(value % 10,u8);
i += 1;
value /= 10;
value != 0;
} {}
j := 0;
while j < i {
putc result[j];
j += 1;
}
};
to_u64 :: (value:string) -> u64 {
i :u64= 0;
result :u64= 0;
while i < value.length {
c := value[value.length-i-1];
result *= 10;
result += @cast(c - '0',u64);
i += 1;
}
return result;
};
|