Here you can ask questions and find or give answers to organizational, academic and other questions about studying computer science.

870 questions

988 answers


439 users

+2 votes

The excercise :
The following exercise will handle binary (Radix 2) fixed-point numbers.
Should numbers not fit (i.e. too many decimal places) 'Round To Nearest Even' should be used.
b) Encode 2.544921875 as a binary fixed point number with 5 decimal places.

I`m not really sure how to convert it into a fixpoint number, 
My approch:

2.544921875 * 25  = 81,4375 and then I have rounded the number to the nearest even : 82 and converted it back to binary 01010010. But the auto correction said the answer is wrong.
Should I round to 
81,438? When yes how do I represent that number in binary

in # Mandatory Modules Bachelor by (230 points)

1 Answer

+2 votes

After scaling up by 25 we are left with the remainder 0.4375. It is less than 0.5 so we round down. If it was more than 0.5 we would round up. "To nearest even" only comes into play if we have exactly 0.5. This is why it's called a tie-breaking rule (0.5 is a tie between up and down).

by (2.4k points)
I have a similar question. My number is 7.8125 and 3 decimal places are requested. So I multiplied my number with 2^3 and got 62.5 so since its 0.5 I rounded ot nearest even which is 62. That as a B-complement is <[1000000]>2 but the system says is wrong.
Your reasoning for 62 is correct. But 62 is not <[1000000]>2 in 2-complement. That would be <[0111110]>2. And <[1000010]>2 for -62.

Furthermore the exercise does not ask for complement numbers. It is possible to use complement numbers for fixpoint numbers, but we don't need that here. So you can encode 62 simply as a radix-2 number.
I just realised I converted 64 instead of 62, my bad I guess. Thank you for your explanation!

Related questions

+1 vote
1 answer
0 votes
1 answer
asked Aug 23, 2020 in # Mandatory Modules Bachelor by davidschulz (410 points)
0 votes
1 answer
asked Aug 23, 2020 in # Mandatory Modules Bachelor by kremenadla (380 points)
0 votes
1 answer
0 votes
1 answer
Imprint | Privacy Policy