|
|
@ -1,5 +1,5 @@
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Bit manipulations is a very powerful tool just also from Zig.
|
|
|
|
// Bit manipulation is a very powerful tool, also from Zig.
|
|
|
|
// Since the dawn of the computer age, numerous algorithms have been
|
|
|
|
// Since the dawn of the computer age, numerous algorithms have been
|
|
|
|
// developed that solve tasks solely by moving, setting, or logically
|
|
|
|
// developed that solve tasks solely by moving, setting, or logically
|
|
|
|
// combining bits.
|
|
|
|
// combining bits.
|
|
|
@ -8,10 +8,10 @@
|
|
|
|
// functions where possible. And it is often possible with calculations
|
|
|
|
// functions where possible. And it is often possible with calculations
|
|
|
|
// based on integers.
|
|
|
|
// based on integers.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Often it is not easy to understand at first glance what exactly these
|
|
|
|
// At first glance, it is often not easy to understand what exactly these
|
|
|
|
// algorithms do when only "numbers" in memory areas change outwardly.
|
|
|
|
// algorithms do when only "numbers" in memory areas change outwardly.
|
|
|
|
// But it must never be forgotten that the numbers only represent the
|
|
|
|
// However, it should never be forgotten that the numbers only represent
|
|
|
|
// interpretation of the bit sequences.
|
|
|
|
// the interpretation of the bit sequences.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Quasi the reversed case we have otherwise, namely that we represent
|
|
|
|
// Quasi the reversed case we have otherwise, namely that we represent
|
|
|
|
// numbers in bit sequences.
|
|
|
|
// numbers in bit sequences.
|
|
|
@ -21,7 +21,7 @@
|
|
|
|
// Zig provides all the necessary functions to change the bits inside
|
|
|
|
// Zig provides all the necessary functions to change the bits inside
|
|
|
|
// a variable. It is distinguished whether the bit change leads to an
|
|
|
|
// a variable. It is distinguished whether the bit change leads to an
|
|
|
|
// overflow or not. The details are in the Zig documentation in section
|
|
|
|
// overflow or not. The details are in the Zig documentation in section
|
|
|
|
// 10.1 "Table of Operators".
|
|
|
|
// "Table of Operators".
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Here are some examples of how the bits of variables can be changed:
|
|
|
|
// Here are some examples of how the bits of variables can be changed:
|
|
|
|
//
|
|
|
|
//
|
|
|
|