0
$\begingroup$

After having spent a significant amount of time googling this topic, I am still struggling to confidently answer the following question:

Identify the process using logical operators to normalise a floating-point number.

My first assumption was, we use the binary shift to remove the leading 0's (for positive numbers) or 1's (for negative numbers) and then use XOR to increase the exponent by the required amount.

I do not understand, however, what happens to the binary point.

Let's say we have the number 1.75 represented as 000001.11 in 8-bits. If I shift it to the right by one place, I lose the 1 at the end. If I shift it to the left by 4 places, how does the computer know to move the binary point between the first two bits from the left? I am lost. How do bitwise operations work in this case?

Thank you in advance for your time and help.

$\endgroup$
  • $\begingroup$ Where does the prompt quoted come from? There should be a context with details about normalised floating-point number. $\endgroup$ – greybeard Sep 23 at 6:49
  • $\begingroup$ Very strange question. Was that written by a native English speaker? $\endgroup$ – gnasher729 Oct 22 at 12:54
0
$\begingroup$

It's helpful to think of the number in the following representation( I choose 3.75 as an example): $$2^0 * 11.11_2 = 3.15$$ Now $2^0 = 1$ so we can just write it in front of the number. Now we want to normalize $3.75$ meaning we need to transform it to $2^e * 1.m$ where $e$ and $m$ are some bitstrings. Notice that we can shift a binary number to the left by dividing it by to e.g. $4 = 100_2 = 2* 010_2 = 2*2* 001_2$. I hope you can see how dividing/multiplying by 2 corresponds to shifting (in base 2!). Lets shift 3.75 in such a way that a 1 is in front of the comma: $2^0 * 11.11_2 0 = 2^1* 1.111_2$; as you can see we shifted 3.75 and thereby pulled a $2$ out of it and increased the exponent to account for the $2$. The value of the number is still 3.75 it's just written down as $2* 1.875$. This is the normalized form. Now the exponent $e$ and the places behind the comma are stored in a floating point number. Why don't we need the $1$ in front of the comma? Cause the normalized form guarantees that there is a 1 so it's redundant to store it.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ for details on how the number is stored and how negative numbers and e.g. zero are represented in e.g. the IEE 754 float32 format check out en.wikipedia.org/wiki/IEEE_754 $\endgroup$ – plshelp Sep 22 at 2:40
  • $\begingroup$ Thank you! It's not quite what I meant though. I do understand how normalisation is done and why it is done. I just don't know how to account for the fact that in the example I've given above, the first 1 on the right would disappear if I shifted the bits to the right by one place in order to normalise the number. A shift to the right puts the 1's outside the range of 8-bits, no? And then, how do I get rid of leading 0's, whilst simultaneously keeping the binary point in front of 1's. $\endgroup$ – DeadManProp Sep 22 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.