I’ve been given these two questions, and I can’t wrap my head around floating point properly, so if someone could offer some pointers as to how I should work these questions out, I’d be very grateful.
-
What is the smallest and largest
number that can be represented in 2s
compliment normalised floating point
notation with 10 bit mantissa and 6
bit exponent? -
What are the two closest values to 0
possible with the above mantissa and exponent.
Think where underflow and overflow
occurs.
If you’re talking about an IEE754 variant, you can examine Wikipedia IEEE754-1985 and work out the calculations for fully normalised number yourself, given the different sizes for the fraction and exponent.
Forget the sign for now, that’s just a simple bit-flip.
The biggest fraction is all one-bits which, for a ten-bit mantissa, is:
(the implicit
1plus ten bits of ever-halving fractions). That’s2047/1024.Regarding the exponent, the highest non-special value (special values are things like
NaNor±Inf) for a 6-bit exponent is 26-2 or 62 (the range is 0 thru 62).But, because you need positive and negative exponents, you subtract 31 (the bias, half the maximum non-special value). This gives you the range -30 thru 31 (-31 can be discounted here since it’s not normalised).
So the largest and smallest (most negative) values are
±(2047/1024)x231or±4292870144.Similarly, the two values closest to zero have an exponent field of -30 (the minimum normalised) and a mantissa field of all zeroes which, with the implicit
1, gives you1.Those values are
±(1)x2-30or±0.000000000931322574615478515625.You should print out that Wikipedia page and this answer and sit down with both until you understand them. I don’t mind helping you out here but, if you regurgitate my answer for your homework, you will almost certainly be caught out (if your educators have any intelligence, though there’s no guarantee of that).
In order to put this answer into your own words (and hence not get caught out for plagiarism), you’ll have to understand it.