Hello, i am a student majoring in computer science, we are learning C++. We have an exam coming up soon and i need help understanding a certain concept that our professor has been teaching. I am not really understanding his explanations at all and was wondering if anyone here could explain better.
The instructions for a table, similar to a truth or logic tabel in math is given:
Use the following declarations and initializations as you evaluate the following expressions:
unsigned int a = 0xB5, b = 0x9D, c = 0x3E;
Answers should be shown in hexadecimal. Assumptions:
•
unsigned ints are 8 bits in length,
•
the rightmost bit in the internal representation (the least significant bit) is numbered 0, and
•
the leftmost bit in the internal representation (the most significant bit) is numbered 7.
What i am wondering is what each integer is defined as...so what is 0xB5, 0x9D, and 0x3E. i do not understand exactly what this means and hwo to fit it in the table with operators such as
!a
~b
!!c
~(!b)
!(~a)
a && b
if anyone could help me, it would be much appreciated. thank you!
A hexadecimal number like 0xB5 is just another representation of the decimal number 181
The standard windows claculator 'calc.exe' can convert these numbers for you
To figure the answer to bitwise operations by hand, you have to convert the numbers to binary. The nice thing about getting the input and output in hex is that it's easy to convert between hex and binary: each hex digit translates directly to 4 bits. For example, to compute ~a:
a = 0xB5
= 1011 0101 (binary)
~a= 0100 1010 (binary)
= 0x4A