Last active
September 17, 2020 17:22
-
-
Save Adobe-Android/11083f695d618582efe3d5d27636c1eb to your computer and use it in GitHub Desktop.
A comparison of int_fast and int_least at various guaranteed sizes (will vary based on system architecture and whether the program is 32 or 64-bit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() { | |
// Optimizes for speed over memory use. | |
// On modern machines, int_fast16_t will often instead be 32-bit, consuming 4 bytes like | |
// int_fast32_t. This is actually better for performance. | |
std::cout << sizeof(int_fast16_t) << '\n'; | |
std::cout << sizeof(int_fast32_t) << '\n'; | |
std::cout << sizeof(int_fast64_t) << '\n'; | |
// Optimizes for the smallest size (least amount of memory) that can guarantee the specified size. | |
std::cout << sizeof(int_least16_t) << '\n'; | |
std::cout << sizeof(int_least32_t) << '\n'; | |
std::cout << sizeof(int_least64_t) << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment