diff --git a/lab04/main.cpp b/lab04/main.cpp index 805be3c..9c5f7a2 100644 --- a/lab04/main.cpp +++ b/lab04/main.cpp @@ -18,22 +18,11 @@ char nibble_to_hex(uint8_t i) //Conversion to hex format } } -uint8_t jun_nibble(uint8_t i) //Extracting the junior Nibble -{ - return i & 0x0f; -} - -uint8_t sen_nibble(uint8_t i) //Extracting the senior Nibble -{ - return (i & 0xf0) >> 4; -} - void print_in_hex(uint8_t byte) { - //uint8_t upper_nibble = sen_nibble(byte); - //uint8_t lower_nibble = jun_nibble(byte); - //cout << nibble_to_hex(upper_nibble) << nibble_to_hex(lower_nibble) << endl; - cout << nibble_to_hex(sen_nibble(byte)) << nibble_to_hex(jun_nibble(byte)) << endl; +cout << nibble_to_hex(byte >> 4) + << nibble_to_hex(byte & 0xf) + << endl; } int main() @@ -58,11 +47,9 @@ int main() uint8_t byte = 0xce; - //cout << "Jun: " << jun_nibble(byte) << endl; - //cout << "Sen: " << sen_nibble(byte) << endl; - print_in_hex(byte); + cout << "Press any key for exit... "; cin.get(); return 0;