Ee222 Lab Report 1
Ee222 Lab Report 1
Ee222 Lab Report 1
Submi ed By:
Equipment:
A working computer
Introduction
In computer ideology, a number system is considered the method used for numbering and
representing digits within the computer's internal system. This can be known as a ‘technique
used in representing numbers in computer system architecture’ [1]. The total number of digits
utilized in a number system is referred to as its base or radix, which is denoted by a subscript
following the number. For example, “1000110 (1000110 base 2)” [1]. There are four main
types of number systems that computer systems support which are:
(Source: [2])
Decimal Number system composes ten numerals starting from 0 to 9 of base 10. These digits
can express any quantity in base 10 [3]. The binary system includes only two numerals which
are 0 and 1 of base 2 [1]. This system is commonly used in machine language by computers
to comprehend program instructions. Octal number systems work with eight digits from 0 to
7 with base of 8 [1]. Finally, Hexadecimal system which comprises of 16 digits from 0 to F.
The numerals last till nine then it uses letters from A to F that represent numerals 10 to 16
[3].This is mostly used by computer programmers as it can be easier to convert from
hexadecimal to binary for the computer to perform the required tasks.
Unsigned numbers are characterized by having no sign and containing only the magnitude of
the number. Therefore, when representing positive decimal numbers, it remains the same and
no sign bit is present in unsigned binary. In signed numbers, there are three ways to represent
binary numbers which are ‘Sign-Magnitude’, ‘1’s complement’ and ‘2’s complement [4].
(Source: [4])
In Sign Magnitude, the bit in the left most side in binary is also the most significant bit, is
assigned to represent the sign. If the sign bit is 0, it signifies a positive number whereas a
value of 1 indicates a negative number. The other bits portray the size or magnitude of the
number [4].
Another method is when the positive numbers need to be in form of regular binary numbers
and negative numbers need to be presented as 1’s complement. An extra bit is used for sign
representation where it is similar to sign and magnitude where positive is represented by 0
and negative by 1 [4]. If the sign bit is set to 1 in binary, the given number is then negative
and 1's complement is used as a representation of it by inverting each bit of the binary
number. But since these two methods can produce overflow or miscalculations in arithmetic
operations, 2’s complement is implemented where it is simply the continuation of 1’s
complement but adding one to counter the overflow produced [4].
Methodology
a. Unsigned Digits
Flowchart diagrams were drawn to illustrate the transformation between any two integers
using the bases of decimal, binary, octal, and hexadecimal. At first, it was designed to work
with unsigned numbers but later some modifications were implemented to the approach to
include any number, with formally defined bounds for every base. Then few numbers were
used as estimates to verify the conversions and observe the accuracy of the flowcharts.
b. Signed Digits
This time the conversion process was for signed numbers. The conversion from decimal to 1's
complement, 1's complement to decimal, sign and magnitude to decimal, sign and magnitude
to 2's complement, and decimal to 2's complement was represented using flowcharts with
their symbols. When verifying the calculations, few estimates were used again to check the
accuracy of the flowchart. When building these flowcharts, the symbols were considered for
better comprehension and functionality.
(Source: Lab Handout)
Binary
Binary to decimal
Binary to octal
Binary to Hexadecimal
Decimal
Decimal To binary
` Decimal to octal
Decimal to hexadecimal
Octal
Octal to binary
Octal to decimal
Octal to hexadecimal
Hexadecimal
Hexadecimal to binary
Hexadecimal to octal
Hexadecimal to decimal
Part II
Decimal to 2’s complement
2s complement to decimal
.
Decimal to sign & magnitude
Decimal to 1’s complement
1’s to decimal
Discussion:
The flowchart for converting between number bases begins by receiving the input number
and its base, proceeding to convert it to decimal if necessary. Error handling is integrated to
detect invalid inputs like negative numbers for unsigned conversions, ensuring proper
handling and halting the process with an error message when necessary. Testing involves
examining the flowchart with diverse sample numbers and edge cases to verify accuracy and
efficiency, refining the flowchart iteratively based on testing outcomes. Moving forward to
handle signed numbers, the approach entails extending the logic to accommodate the sign bit,
incorporating specific conversion methods for each representation like 2’s complement or
sign and magnitude, and considering error handling for overflow conditions or invalid inputs.
Thorough testing and refinement will be crucial for ensuring accuracy and reliability across
different signed representations.
Conclusion
In conclusion, the flowcharts were constructed detailing the conversion process of any
unsigned integer into a signed number, including various bases has been accomplished. It
covers all the conversions from decimal to binary, octal, hexadecimal, sign and magnitude,
sign and magnitude to decimal, and decimal to 2's complement. Number systems are
important in computers and even the daily lives of people as it allows to represent and
manipulate data in various ways in computer programming.
References