1. Convert 0b00110011 to Decimal
| numerical value of position | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bits | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
Ans → 51
2. Convert 0o7654 to Hexadecimal
Step 1: Convert to binary
| Octal (0o) | 7 | 6 | 5 | 4 |
|---|---|---|---|---|
| Binary (0b) | 111 | 110 | 101 | 100 |
Step 2: Regroup into fours, starting from the least significant bit
From this → 111 110 101 100
To this → {111 1} {10 10} {1 100}
Step 3: Convert to Hexadecimal
| Binary (0b) | 1111 | 1010 | 1100 |
|---|---|---|---|
| Hex (0x) | F | A | C |
Ans → 0xFAC
3. Convert -5 to 2’s Complement. Express the answer as an 8 bit binary
5 expressed as an 8-bit binary → 0b00000101
Now, we convert it to -5 expressed as a 2’s Complement binary:
- Invert: 0b00000101 → 0b11111010
- Add 1: 0b11111010 + 1 = 0b11111011
- Yuhhhhhh
4. Convert 0x8F00 to Decimal
Step 1: Break into Binary
| Hex (0x) | 8 | F | 0 | 0 |
|---|---|---|---|---|
| Binary (0b) | 1000 | 1111 | 0000 | 0000 |
Step 2: Count! just like in qn 1!
You should b able to get this:
BUT WAITTT, there’s a trick for this. Getting “32,768” should be fairly straight forward (u should have this memorised). But the addition of the rest is very tedious. So, what you could do instead, is:
| Original Binary (0b) | 1000 | 1111 | 0000 | 0000 |
|---|---|---|---|---|
| “Added” Binary | 0000 | 0001 | 0000 | 0000 |
| “Rounded Up” Binary | 1001 | 0000 | 0000 | 0000 |
| So, we’ve added another binary number to the equation to round up the original number. |
This is rounded up binary is MUCH easier to calculate!
But we have to remove our rounding errors…
We added 0b 0001 0000 0000 to round up our original binary, so we have to subtract it from !
So the full equation is →
Multiplication Method
| Hex (0x) | 8 | F | 0 | 0 |
|---|---|---|---|---|
| Decimal Value | 0000 | 0000 |
ANS →
This might b faster since ya’ll are allowed scrap paper to do multiplication! Whichever floats ur boat
5. Solve NOT((7 OR 5) XOR 10)
Also can be expressed as → ~((7 | 5)^10)
Step 1: Convert to binary
~((0b111 | 0b101) ^ 0b1010)
Step 2: solve inner statement (0b111 | 0b101)
| Bitwise OR | |||
|---|---|---|---|
| 0b111 → | 1 | 1 | 1 |
| 0b101 → | 1 | 0 | 1 |
| Output | 1 | 1 | 1 |
(0b111 | 0b101) = 0b111
Step 3: solve remaining statement ~(0b111 ^ 0b1010)
| Bitwise XOR | ||||
|---|---|---|---|---|
| 0b111 → | 0 | 1 | 1 | 1 |
| 0b1010 → | 1 | 0 | 1 | 0 |
| Output | 1 | 1 | 0 | 1 |
~(0b111 ^ 0b1010) = ~0b1101
= 0b0010
= 2 ← ANS