At 02:02:00 of
https://hero.handmade.network/episode/win32-platform/day025, it's commented that direct casting may cause the compiler to "round" to the closest uint32, instead of picking up low 32bits solely.
However, according to C11:
1. When a value with integer type is converted to another integer type other than _Bool, if the value can be represented by the new type, it is unchanged.
2. Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.
Therefore, casting solely is sufficient here.
```
#include <stdio.h>
#include <stdint.h>
#include <limits.h>
int main(int argc, char *argv[])
{
uint64_t x = ((uint64_t)1 << 32) + 1;
uint32_t y = (uint32_t) x;
printf("%lu\n", x);
printf("%u\n", UINT_MAX);
printf("%u\n", y);
return 0;
}
```
prints:
```
4294967297
4294967295
1
```