Last active
August 21, 2018 20:35
-
-
Save xentec/d78e4739ac937853f45884371aebf1ef to your computer and use it in GitHub Desktop.
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
#include <cstdint> | |
#include <fmt/format.h> | |
int main() | |
{ | |
union { | |
uint32_t i; | |
uint8_t a[4]; | |
struct { uint32_t lsb:6, m:20, msb:6; } b; | |
}; | |
i = 0xFF02FF40; | |
fmt::print("ARRAY: "); for(int j=4;j>0;--j) fmt::print("{:08b}", a[j-1]); fmt::print("\n"); | |
fmt::print("INT: {:032b}\n", i); | |
fmt::print("FIELDS: {:06b}{:020b}{:06b}\n", b.msb, b.m, b.lsb); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment