From 46d10b325c423ffefa5db1d46e4dd75d68b1f8bf Mon Sep 17 00:00:00 2001 From: KleptsovKD Date: Mon, 3 Feb 2025 20:49:33 +0300 Subject: [PATCH] extracting_junior_nibble --- lab04/main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lab04/main.cpp b/lab04/main.cpp index 46f52de..9934cd3 100644 --- a/lab04/main.cpp +++ b/lab04/main.cpp @@ -3,6 +3,7 @@ using namespace std; +//char nibble_to_hex(uint8_t i) char nibble_to_hex(uint8_t i) //Conversion to hex format { assert(0x0 <= i && i <= 0xf); @@ -17,7 +18,10 @@ 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; +} int main() @@ -40,6 +44,9 @@ int main() assert(nibble_to_hex(0xe) == 'e'); assert(nibble_to_hex(0xf) == 'f'); + cout << nibble_to_hex(10) << endl; + //cout << hex << static_cast(jun_nibble(0xce)) << endl; + cout << "Junior nibble: " << hex << +jun_nibble(0xce) << endl; //junior nibble cout << "Press any key for exit... "; cin.get();