Pregunta

How do I write 0xFA in signed mantissa. I converted it to binary = 1111_1010. Not sure where to go from here.

The question is "If the register file has 8 bits width total, write the following in signed mantissa."

Also, an explanation of signed mantissa would be great!

¿Fue útil?

Solución

So what you have to work with is a byte of data with an unknown type, apparently.
In order to write a number in signed mantissa (see Significand) one would expect that your dealing with a floating point type such as single or double. However you've only got a single byte.

A single is 8 bytes so surely it can't be that and double is double trouble. Also a half requires 16 bits. The only logical alternative type would be SByte but in that case you will never get any numbers that have any mantissa (significant digits) after the decimal. In fact there is no decimal. So Perhaps this is a trick question?

If you go on the assumption of SByte, you get -6x10^0

Just in case you want proof, or if your curious how this looks during debug:

    private void SByte2Dec()
    {   
     sbyte convertsHexToSByte = Convert.ToSByte("0xFA", 16);
     Single yourAnswer = Convert.ToSingle(convertsHexToSByte);
     label1.Text = Convert.ToString(youranswer);
    }

In this example I had a windows form with nothing but label1 on it.
Then I put SByte2Dec(); right under InitializeComponent();


  • The solution is -122. Not sure how to get there...any ideas?

Working backwards from the answer it's simple to see what your professor has done. He is assuming the MSB is the sign bit and the rest is treated like a 7 bit integer. There is a precedent for this, called "Signed Magnitude Representation" but it's not used in modern computing. These days pretty much everyone is using Two's compliment.

I take it this is a beginners course and rather than go though all the trouble of explaining two's compliment and data types your professor is mainly trying to drive home the point of the MSB being a sign bit. If you got the whole sign bit thing and don't know anything else about the way modern computer hardware performs calculations, then you would probably arrive at the same answer.

My guess is that your professor also took to wording the question in a strange way so as to throw you off the path if you tried to Google the answer. If you want to get him back, ask him what the difference between "1000 0000" and "000 0000" is. Also if you or anyone else in the class answered -6 and he counted it wrong, he should be fired. Those students should be awarded bonus points for teaching themselves about two's compliment.


  • Why would the signed mantissa be -6? I see that the 2's complement is -6 but signed mantissa is different?

I have you read the wiki article I linked to on "Significand"? The important thing to realize is that "signed mantissa" is not a data type. However, there are (were?) many different machine-specific data types that implemented their own versions of storing floating point numbers before the IEEE standard became widely adopted. These early data types were often referred to as DFP or decimal floating point numbers as opposed to binary floating point. Read this paper and for more in-depth understanding. Also this paper covers the topic quite well.

As I stated earlier, your professor most likely used the terminology "signed mantissa" to throw you off if you went searching the internet for the answer. Apparently you were expected to read between the lines and know that what he was really asking for was a form of decimal floating point, or Signed Magnitude Representation.

"Signed Mantissa" Two's Compliment

"Signed Mantissa" is to be interpreted as some form of Decimal Floating Point
Where as, Two's Compliment is a form of Binary Floating Point

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top