CSC 230 Lab 1 Lab Environment and Number Systems Solved

30.00 $

Category:

Description

5/5 - (1 vote)

II. Number Systems

In the computer system, we need to know how many bits (storage space) are used. For example, let’s count the number of students in the lab. In decimal number system, we just need two digits. In the binary number system, how many bits do we need?

Let’s do counting up in decimal, binary and hexadecimal. The conversion table up to the decimal value of 22 is provided below. Having a systematic way of counting, you should be able to come up with a conversion table that is indefinitely long on your own

IV. Exercises

  1. Why do we use 5 bits in the table in part II (the number of students attending the lab)? Can we use only 4-bits instead?
  2. How many different values can be represented by 6 bits?
  3. There are 194 students registered in CSc 230, what is the minimum number of bits needed to represent this number in binary (assume it is an unsigned number)?
  4. Convert the following positive integer numbers:
    1. 0b1001101 to decimal
    2. 261 to binary
    3. 153 to hexadecimal
    4. 0x1FE to decimal
  1. Convert the following numbers using 2’s complement notation:
    1. -63 to binary
    2. -123 to hexadecimal
    3. 0b101011 to decimal
    4. 0b001110 to decimal

 

  1. What are the minimum and maximum values (in decimal) represented by a 4-bit binary number:
  2. a) as an unsigned number? b) as a signed number (2’s complement)? How about 8 bits, 16 bits? Can you come up with an equation for any number of bits, let’s say k?

For example, given a 2-bit number, the answer is:

Number of bits                                  Unsigned                        Signed

2                                                             [0, 3]                                   [-2,1]

  1. What is the result of bitwise AND operation on 0b10110010 with 0b11110000?
  2. What is the result of bitwise XOR operation on 0b11000101 with 0b11110000?
  3. What is the result of the logical left-shift operation on 0b01011101? How about right-shift?
  4. Recall that the position of each bit in a binary number is associated with its power; for example, in one byte, the positions are 2726252423222120. What is the 8-bit binary number x (also called a mask) to be used if we want to clear the bits at positions 2, 3, 5, and 7 in a given byte?
  • Lab1-vpipe7.zip