|
|
|
@ -58,11 +58,27 @@ void test_print_array_in_hex() {
|
|
|
|
|
cout << "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char bit_digit(uint8_t byte, uint8_t bit) {
|
|
|
|
|
return (byte & (1 << bit)) ? '1' : '0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void print_in_binary(uint8_t byte) {
|
|
|
|
|
for (int8_t bit = 7; bit >= 0; --bit) {
|
|
|
|
|
cout << bit_digit(byte, bit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_print_in_binary() {
|
|
|
|
|
print_in_binary(0x2a); cout << "\n"; // 00101010
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
test_nibble_to_hex();
|
|
|
|
|
test_nibbles();
|
|
|
|
|
test_print_in_hex();
|
|
|
|
|
test_print_array_in_hex();
|
|
|
|
|
test_print_in_binary();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|