Assignment 1
Assignment 1
Specifications
A number system is defined as the representation of numbers by using digits or other symbols in
a consistent manner. The value of any digit in a number can be determined by a digit, its position
in the number, and the base of the number system. The numbers are represented in a unique
manner and allow us to operate arithmetic operations like addition, subtraction, multiplication,
and division.
This assignment consists of designing C programs to convert numbers from one number system
to another number system. Although many number systems (decimal, binary, octal, hexadecimal,
real, fixed point, and floating point) exist in the literature, this assignment focuses only on
decimal, binary, hexadecimal, real, and fixed point numbers. A number can be either signed or
unsigned. Unsigned numbers are always positive, while signed numbers are either positive or
negative. In this assignment, we are focusing on the unsigned numbers only. Signed numbers will
be dealt with the next assignment.
The decimal number system uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 and the base 10. The
decimal number system is the system that we generally use to represent numbers in real life.
The binary number system uses only two digits: 0 and 1 and the base 2. Digits 0 and 1 are called
bits. Binary numbers are easy to process and store in the computers and all computers present
in the world now use binary numbers as its internal number system.
1|Page
CSCI 261: Computer Architecture and Assembly Language
Any number that can be found in the real world is a real number. We find numbers everywhere
around us. Natural numbers are used for counting objects, rational numbers are used for
representing fractions, and irrational numbers are used for calculating the square root of a
number, integers for measuring temperature, and so on. These different types of numbers make
a collection of real numbers.
In computer systems, real numbers are stored as either fixed point or floating point binary
numbers. As mentioned before, we are focussing on unsigned real numbers and unsigned fixed
point numbers. Each unsigned fixed point binary number has two important parameters that
describe it; the position of the radix point in relation to the most significant bit and the number
of fractional bits. For example, a 16-bit fixed point number system can be represented as
U(10,6) to indicate that there are six bits of precision in the fractional part of the number, and
the radix point is ten bits to the right of the most significant bit stored. The layout for this number
is shown graphically as:
In this assignment, we are using a 32-bit unsigned fixed point number system U(16,16) to store
an unsigned real number, i.e., there are sixteen bits of precision in the fractional part of the
number, and the radix point is sixteen bits to the right of the most significant bit stored.
Tasks
1. You will submit this assignment using GIT submission system. A central repository named
‘assignment1” has been created for this assignment.
2. Create your own fork of assignment1 on the central GIT repository using following
command.
ssh csci fork csci261/assignment1 csci261/$USER/assignment1
2|Page
CSCI 261: Computer Architecture and Assembly Language
assignment1 bin
build
example
bin
build
cmake
include
resource
src
test
include
resource
src
assn
CMakeLists.txt
README
A README file template has been placed in the root folder. The README file will give a
general idea to the users of the application developed in your assignment, technologies used
in the application, how to build and install the application, how to use the application, list of
contributors to the application, and what type of license you give to the users of the
application. You will need to complete the README file before your final submission.
The specifications or header files (convert.h and utility.h) have been placed in include sub
folder.
3|Page
CSCI 261: Computer Architecture and Assembly Language
All source codes (convert.c, utility.c, and main.c) go into src sub folder. You need to
implement the functions defined in the header file utility.h in your source code file utility.c.
You need to implement the functions defined in the header file convert.h in your source
code file convert.c. The main.c file in the src folder is complete, it uses the functions from
your source code in convert.c and utility.c. You don’t need to must not modify main.c file.
Test codes to unit test all the functions of this assignment are given in tests.c file in test/src
folder. You don’t need to and must not modify the test codes. You can check the unit test
code against each function to get an idea, how that function is being tested. Your code has
to pass the unit test of a function to get marks on its implementation.
You will use cmake build tool to build your assignment. A CMakeLists.txt has been placed in
the root, src, and test folders for cmake to use, you don’t need to and must not modify
CMakeLists.txt files. All build artifacts will be placed in build sub folder and executable files
in bin sub folder by cmake.
Data files are usually placed in resource folder. There is no data file in resource folder in this
assignment.
A bash script named assn has been placed in the root folder. You will use this script to build,
clean, run, and test this assignment.
6. One example executable (assignment1) of this assignment has been placed in the
example/bin folder. You can run this example executable to get an idea what is expected
from you in this assignment. To run the example executable type the following from the
assignment root folder:
./assn run-example
7. One example test executable (assignment1_test) of this assignment has been placed in the
example/build folder. You can run this example test executable to get an idea what tests
your code has to pass. To test the example executable type the following from the assignment
root folder:
./assn test-example
Above example executables have been built and tested in Linux Debian machines available in
the labs. Run these executables in other kind of machines at your own risks. Command ‘./assn
clean’ will not delete these example executables and you should not delete them either.
8. Type following at the command prompt to clean previously built artefacts of the assignment:
./assn clean
4|Page
CSCI 261: Computer Architecture and Assembly Language
9. Type following at the command prompt to build the application from your own source code:
./assn build
10. Type following at the command prompt to run your own code:
./assn run
11. Type following at the command prompt to test your own code:
./assn test
12. Type following at the command prompt to debug your own code using gdb:
./assn debug
13. Type following at the command prompt to check memory leak in your own code:
./assn memcheck
14. Type following at the command prompt to profile your own code:
./assn profile
15. Make sure you can compile, link, run, and test this application error and warning free.
16. Complete the README file. Therefore, you need to give the general description of the
application, technologies that are used in the application, how a user can build (compile and
link) and install the application, how a user can run the application after the installation.
Mention instructor’s name and your name in the list of contributors. Give GPL license to the
users to use the application. You can google to find README examples if you are not sure
how to write one.
17. Organize and comment your code to make it easy to understand. Make sure you have typed
your name and student number in the top comment section in each .c file. Make sure you
have deleted all debugging print codes that you were using to debug your code during your
development time but not necessary in the final code. Also, make sure you have deleted all
commented out codes from your final submission.
18. Continue your work in your cloned or local assignment1 repository and commit and push
your work to your central assignment1 repository as it progresses.
5|Page
CSCI 261: Computer Architecture and Assembly Language
The deadlines to demonstrate this assignment in the lab are September 26, 2023 for sections F23N01,
F23N02, F23N03 and September 28, 2023 for section F23N04.
You will find most useful git commands in this git cheat sheet from GitLab. You will be allowed
to commit and push until the deadline is over. Incremental and frequent commits and pushes
are highly expected and recommended in this assignment.
6|Page
CSCI 261: Computer Architecture and Assembly Language
Evaluation
Module Functions Marks
utility.c reverse 3
extend_integer_binary 4
extend_fraction_binary 4
are_decimal_digits 2
are_binary_digits 2
is_decimal 2
is_binary 2
is_real_integer_part 2
is_real_fraction_part 2
is_fixed_point_part 2
is_real 2
is_fixed_point 2
get_integer_part 3
get_fraction_part 3
convert.c integer_to_binary 4
decimal_to_binary 4
binary_to_integer 4
binary_to_decimal 4
integer_part_to_binary 4
fraction_part_to_binary 5
real_to_fixed_point 5
binary_to_integer_part 5
binary_to_fraction_part 5
fixed_point_to_real 5
README 05
Code Quality and 15
Comments
Total 100
7|Page