December 2021
Intermediate to advanced
352 pages
9h 32m
English
I rank type safety close to deterministic destruction among my favorite features of C++. Type safety tells different parts of your program what a bit pattern means. For example, here is the bit pattern for 1,729 as a 32-bit integer:
std::int32_t Ramanujan_i = 0b0000'0000'0000'0000'0000'0110'1100'0001;
Here is the bit pattern for 1,729 as a 32-bit unsigned integer:
std::uint32_t Ramanujan_u = 0b0000'0000'0000'0000'0000'0110'1100'0001;
As you can see, it is identical. However, consider the bit pattern for 1,729 as a float:
float Ramanujan_f = 0b0100'0100'1101'1000'0010'0000'0000'0000; ...
Read now
Unlock full access