In: Electrical Engineering
Which of the following number formats can be used to represent all integers in the range 0 to 4,294,967,295?
A) unsigned integer (32 bits)
B) sign magnitude (32 bits)
C) two's complement (32 bits)
D) floating point format (IEEE754 single precision)
(a) Unsigned Integer (32 bit)
For unsigned Integer repesentation using n bits , the range of numbers that can be represented is 0 to 2n-1.
For example, if we have two bits, then we can represent 0 to 3.
If we have four bits, we can represent 0 to 15.
And if we have 32 bits we can represent 0 to 232-1 i.e., 0 to 4294967295. Hence this representation can be ised.
(B) Sign Magnitude 32 bits.
In this , if we have n bits, the MSB bit is used to represent the sign and the rest n-1 bits are used to represent the magnitude. i.e., here we have 31 bits to represent magnitude. The range is - (2n-1-1)to + (2n-1-1). The maximum positive value that can be represented using 32 bits is 2147483647. Hence this representation cannot be used.
(C) Two's complement 32 bit
The range of numbers that can be represented using n bit 2's
complement is
-( 2n-1) to 2n-1 - 1
Hence this representation also cannot be used. As it would not give the complete needed range.
(D) IEEE754 single precision representation
IEEE 754 32-bit base-2 floating-point variable has a maximum value of (2 ? 2?23) × 2127 ? 3.402823 × 1038. All integers with 6 or fewer significant decimal digits, and any number that can be written as 2n such that n is a whole number from -126 to 127, can be converted into an IEEE 754 floating-point value without loss of precision. Hence this can be used.