作者kizu1124 (\( ̄ー ̄;) >)
看板Grad-ProbAsk
标题[理工] 计组(96台大资工)
时间Sat Sep 26 00:54:50 2009
Perform the following 8-bit 2's complement number operation and check
whether arithmetic overflow occurs. Check your answer by converting to
decimal sign-and-magnitude representation.
1 1 0 1 0 0 1 1
- 1 1 1 0 1 1 0 0
题目是这样@@
我的问题是
"Check your answer by converting to decimal sign-and-magnitude representation."
这一句话 是否代表要将1 1 0 1 0 0 1 1与1 1 1 0 1 1 0 0
用sign-and-magnitude方式,化成10进位数,在相减变成答案呢?
也就是 1 1 0 1 0 0 1 1= -(64+16+2+1) = -83
1 1 1 0 1 1 0 0= -(64+32+8+4) = -108
然後-83-(-108)=25 (这是错的 因为答案是-25)
--
张凡的答案是直接把那两式用2's complement的方式化成10进位 -45-(-20)=-25
还是我误解题意了... 请高手帮我回答 感谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.227.98.199
1F:→ BF3716:应该是指先做2's补数的减法,看是不是有overflow 09/26 01:10
2F:→ BF3716:之後再换成常用的10进制也计算一次,确认答案是不是正确 09/26 01:12
3F:推 bernachom:题目不是要做2补数吗?_?a 09/26 01:34
4F:→ ssccg:decimal sign-and-magnitude representation是一整个字 09/26 04:32
5F:→ kizu1124:欧...原来那算一个字= = 那我懂了 09/26 08:04
6F:→ kizu1124:感谢 09/26 08:04