Created
December 17, 2014 03:02
-
-
Save shanna/6d2a6c91222ba4fa81a4 to your computer and use it in GitHub Desktop.
printf uint64_t binary.
This file contains 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
// Has the advantage of not needing a temp buffer. | |
#define BINARY_8_FORMAT \ | |
"%d%d%d%d%d%d%d%d" | |
#define BINARY_8_PARAMS(byte) \ | |
(byte & 0x80 ? 1 : 0), \ | |
(byte & 0x40 ? 1 : 0), \ | |
(byte & 0x20 ? 1 : 0), \ | |
(byte & 0x10 ? 1 : 0), \ | |
(byte & 0x08 ? 1 : 0), \ | |
(byte & 0x04 ? 1 : 0), \ | |
(byte & 0x02 ? 1 : 0), \ | |
(byte & 0x01 ? 1 : 0) | |
#define BINARY_64_FORMAT \ | |
BINARY_8_FORMAT \ | |
BINARY_8_FORMAT \ | |
BINARY_8_FORMAT \ | |
BINARY_8_FORMAT \ | |
BINARY_8_FORMAT \ | |
BINARY_8_FORMAT \ | |
BINARY_8_FORMAT \ | |
BINARY_8_FORMAT | |
#define BINARY_64_PARAMS(bytes) \ | |
BINARY_8_PARAMS(bytes >> 56), \ | |
BINARY_8_PARAMS(bytes >> 48), \ | |
BINARY_8_PARAMS(bytes >> 40), \ | |
BINARY_8_PARAMS(bytes >> 32), \ | |
BINARY_8_PARAMS(bytes >> 24), \ | |
BINARY_8_PARAMS(bytes >> 16), \ | |
BINARY_8_PARAMS(bytes >> 8), \ | |
BINARY_8_PARAMS(bytes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment