Starting from:
$30

$24

Lab 1: Lab Environment and Number Systems Solution




I. Lab Environment




All students enrolled in CSC 230 need a card to access the lab. More information about access cards is available here: https://servicecatalog.engr.uvic.ca/services/accesscard/. If you don’t have a card, you can purchase it from the bookstore for a non-refundable $10 fee. For card related problems, email engrcard@engr.uvic.ca, include the 5-digit card number, student number, the room, the time and day, and for what course, so that the problem can be solved more quickly.



o Tip: if you purchase the card only, you can go to the computer store (inside the bookstore) and purchase one there to avoid the long line up.




You can also use the access card to gain entry to the ECS building when the doors are locked. Building hours are available here: https://itsupport.cs.uvic.ca/facilities/.
To log in, use your NetLink ID and password. If you have difficulties logging in or printing, you can email itsupport@csc.uvic.ca for help.
ECS 249 is the only lab with hardware/software provided for this course. There are more students in the course than computers in the lab, so consider starting your assignments early to avoid any issues.
Drive “H” is your personal network space on the CSC server. It is also your home directory on the Linux machines. You should store all of your work on drive H and keep a back-up copy on a portable device (e.g. flash drive) or a cloud service of your choosing. Files stored on drive C could be erased without notice. For example, if you saved something on the Windows Desktop or in My Documents folder, they could be irretrievably gone later on the same day.
Information about printing is available here: https://itsupport.cs.uvic.ca/facilities/printing/. Printing is paid for with funds on your UVic ONECard account.






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.








 


Pg. 2
Decimal (2 digits)
Binary (5 bits)
Hexadecimal (2 digits)
0
0b00000
0x00
1
0b00001
0x01
2
0b00010
0x02
3
0b00011
0x03
4
0b00100
0x04
5
0b00101
0x05
6
0b00110
0x06
7
0b00111
0x07
8
0b01000
0x08
9
0b01001
0x09
10
0b01010
0x0A
11
0b01011
0x0B
12
0b01100
0x0C
13
0b01101
0x0D
14
0b01110
0x0E
15
0b01111
0x0F
16
0b10000
0x10
17
0b10001
0x11
18
0b10010
0x12
19
0b10011
0x13
20
0b10100
0x14
21
0b10101
0x15
22
0b10110
0x16












IV. Exercises




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?



How many different values can be represented by 6 bits?



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)?



Convert the following positive integer numbers:



0b1001101 to decimal



261 to binary



153 to hexadecimal



0x1FE to decimal






This lab is based on content originally developed by Dr. Sudhakar Ganti (2016) and revised through the following years by Victoria Li and Tom Arjannikov. The Spring 2020 revision is by Tom Arjannikov.
Pg. 3




Convert the following numbers using 2’s complement notation:



-63 to binary



-123 to hexadecimal



0b101011 to decimal



0b001110 to decimal



What are the minimum and maximum values (in decimal) represented by a 4-bit binary number:



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]




What is the result of bitwise AND operation on 0b10110010 with 0b11110000?



What is the result of bitwise XOR operation on 0b11000101 with 0b11110000?



What is the result of the logical left-shift operation on 0b01011101? How about right-shift?



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?



Submit your solution to exercises 1, 5, and 6 by creating a text file lab1.txt, writing your answers in it, and uploading it via conneX. You must always verify that your solution is accepted by conneX.




Submit lab1.txt at the end of your lab.





























































This lab is based on content originally developed by Dr. Sudhakar Ganti (2016) and revised through the following years by Victoria Li and Tom Arjannikov. The Spring 2020 revision is by Tom Arjannikov.

More products