Data Formats and Arithmetic Operations for each Format

Book Section 2.1.

Rather than accessing individual bits in memory, most computers use blocks of 8 bits, or bytes, as the smallest addressable unit of memory. A machine-level program views memory as a very large array of bytes, referred to as virtual memory. Every byte of memory is identified by a unique number, known as its address, and the set of all possible addresses is known as the virtual address space. As indicated by its name, this virtual address space is just a conceptual image presented to the machine-level program. The actual implementation is by use of combination of dynamic random access memory (DRAM).

Hexadecimal Notation:

A single byte consists of 8 bits. In binary notation, its value ranges from 000000002 to 111111112. When viewed as a decimal integer, its value ranges from 010 to 25510. Hexadecimal (or simply “hex”) uses digits ‘0’ through ‘9’ along with characters ‘A’ through ‘F’ to represent 16 possible values. Written in hexadecimal, the value of a single byte can range from 0016 to FF16. In C, numeric constants starting with 0x or 0X are interpreted as being in hexadecimal. The characters ‘A’ through ‘F’ may be written in either upper- or lowercase. For example, we could write the number FA1D37B16 as 0xFA1D37B, as 0xfa1d37b, or even mixing upper- and lowercase (e.g., 0xFa1D37b).

Conversion between Different Number Systems:

DecimalHexa-DecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111
Number Conversion for Different Bases

Exercise, book 2.1:

Perform the following number conversions:

  1. 0x25B9D2 to binary
  2. binary 1010111001001001 to hexadecimal
  3. 0xA8B3D to binary
  4. binary 1100100010110110010110 to hexadecimal

Exercise, Book 2.2:

n2n (Decimal)2n (Hexadecimal)
5320x20
2383886080x800000
15327680x8000
1381920x2000
1240960x1000
6640x40
82560x100
Exercise, Book 2.2

Exercise, Book 2.3:

DecimalBinaryHexadecimal
0000000000x00
158100111100x9E
76010011000x4C
145100100010x91
174101011100xAE
60001111000X3C
361111100010XF1
4398110101011110011010xabcd
123011110110x7B
117011101010x75
189101111010xBD
245111101010xF5
Exercise, Book 2.3

Exercise, Book 2.4:

Solve below subtraction and addition operations.

  1. 0x605c – 0x5 = _______________________
  2. 0x605c – 0x20 = ______________________
  3. 0x605c + 32 = _______________________
  4. 0x60fa – 0x601fc = __________________

Boolean/Logical Operations:

Operations (bit wise) are ~, &, | , and ^ encode logical operations for not, and, or, and exclusive-or, respectively

  1. AND operation: 0110 & 1100 = 0100
  2. OR Operation: 0110 | 1100 = 1110
  3. Exclusive-OR Operation: 0110 ^ 1100 = 1010
  4. NOT Operation: ~0110 = 1001

Bit Level Operations:

C ExpressionBinary ExpressionBinary ResultHexadecimal Result
~0x41~ 01000001101111100xBE
~0x00~ 00000000111111110xFF
0x69 & 0x5501101001 & 01010101010000010x41
0x69 | 0x5501101001 | 01010101011111010x7D
Bit wise operations

Shifting operations: Book 2.1.9

Exercise, Book 2.16:

OperationsValue 1Value 2
Argument x0110001110010101
x << 4 0011000001010000
x >> 40000011000001001
x >> 4 (Arithmetic)0000011011111001
Shifting operations

Do following exercise by yourself.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Design a site like this with WordPress.com
Get started