6

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.

  1. 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?

  2. What are the two closest values to 0 possible with the above mantissa and exponent. Think where underflow and overflow occurs.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Bojangles
  • 99,427
  • 50
  • 170
  • 208

3 Answers3

2

(I would add this as a comment, but at some point I lost the ability to comment. Perhaps by reputation degraded somehow at some point.)

Make sure you make a distinction between what "smallest number" means, versus what "most negative number" means. These are different and you could lose credit based on which way you answer this on your assignment. Given that the second questions is asking for the smallest numbers representable in this format, I think the first question is actually supposed to be asking for the most negative number (the negative number farthest from zero - the negative number with highest magnitude).

As stated in an earlier answer, I suggest you work these out by hand.

Ask yourself: What combination of sign, exponent, and mantissa would create the largest/smallest numbers? If you know how the conversion from binary to decimal, I think you should be able to easily solve this problem. If you don't know, then I suggest you start there and work your way up.

Zéychin
  • 4,135
  • 2
  • 28
  • 27
  • You need 50 rep to comment. You _had_ 37, now you back above the line. Use that power well, young padawan :-) – paxdiablo Jun 26 '11 at 13:15
  • (Sorry for comment irrelevant to the question, but I figure that I don't have a better place to ask this and I don't understand.) How exactly does one lose reputation? I didn't post inappropriate material or anything. – Zéychin Jun 28 '11 at 04:52
  • It doesn't have to be inappropriate. If you post an question or answer that someone considers not useful, they may downvote you (-2). However, _none_ of your questions or answers have downvotes. You have five answer upvotes (*10=50), 4 question upvotes (*5=20), 3 accepts of answers on your questions (*2=6) and the point you got when you joined. That's 77 which is where you are now. You may have left comments on your _own_ questions and answers, that only needs 1 rep. That's the most likely explanation. See http://stackoverflow.com/faq#reputation. – paxdiablo Jun 28 '11 at 05:43
  • Great. Thank you for taking the time to answer my question and for providing me a relevant link! – Zéychin Jun 28 '11 at 06:55
1

Perhaps you should take a look at these pages: 1, 2, 3, 4, 5, 6, 7

I hope that helps without just giving the answers directly. :)

Btw. have you tried doing the calculations by hand?

Morten Kristensen
  • 7,412
  • 4
  • 32
  • 52
1

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:

      1   1   1    1    1    1    1     1     1      1
  1 + - + - + - + -- + -- + -- + --- + --- + --- + ----
      2   4   8   16   32   64   128   256   512   1024

= 1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
  -----------------------------------------------------
                           1024

(the implicit 1 plus ten bits of ever-halving fractions). That's 2047/1024.

Regarding the exponent, the highest non-special value (special values are things like NaN or ±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)x231 or ±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 you 1.

Those values are ±(1)x2-30 or ±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.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • Thank you very much paxdiablo. I'll take a look at the Wiki page and no, I won't be regurgitating your answer - I asked my question for _learning_ purposes :-) – Bojangles Jun 26 '11 at 12:44
  • I've been looking through all my old questions, and just re-read this answer. I'd upvote it again if I could, and being a year older understand it a lot more than I did back when I posted this question. Thank you for your help once more! – Bojangles May 05 '12 at 22:45