Created
August 18, 2011 08:31
-
-
Save adammw/1153658 to your computer and use it in GitHub Desktop.
pretty cool macros to work out how much space we need (in chars) for a binary number using sizeof
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
| #define BASE2DIGITS_TO_BASE10DIGITS(a) (unsigned)((a * 2.40823997) + 1) | |
| #define NUMDIGITS(type) BASE2DIGITS_TO_BASE10DIGITS(sizeof(type)) | |
| #define UINTBUFFERSIZE (NUMDIGITS(unsigned int) + 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment