Beginner's Guide to Zig Part 3 - Converting Variables, finding index and integer overflows

preview_player
Показать описание
Here I cover how to convert variable types in zig and other things like finding indexes and integer overflows.

Timestamps:
0:00 Introduction
0:21 Cpp/c example of converting variables
1:54 Converting unsigned and signed variables in zig
6:51 Converting similar types
9:54 Cpp/c converting a variable too big
10:44 Truncate
11:56 usize and array indexes
14:51 Cpp/c example of finding an index
16:10 Integer overflows
23:09 Summary

Link to the code used in this series:

If you would like to learn chess, you can check out my game Chess Tools on steam:
Рекомендации по теме
Комментарии
Автор

Aaah, thats learning in my pace. Thanks, underrated video, underrated language.

SYNTAX_NL
Автор

16:00 Where I last worked, it was very important to use the size_t in our C code, and generally _t variants. I'm still learning low level programming, but I think it was to do with it being embedded software having to run on many different platforms. I also couldn't use bool because we had a few platforms (or compilers for those platforms I guess) that didn't support this type.

arngorf
Автор

In your example where number:u8 = 254

You can, as shown in video, "roll over boundary":
number +% 10 // number is 8

But you can also use so called "sentinel" to "stop at (higher or lower) boundary":
number +| 10 // number is 255 which is the max for u8

ericmisha
join shbcf.ru