A+B=>A,没有考虑溢出的可能性,所以是有bug的。

来源: free2005 2013-12-21 19:31:00 [] [博客] [旧帖] [给我悄悄话] 本文已被阅读: 次 (0 bytes)

所有跟帖: 

假设是unsigned。如果有a+b有overflow -g9- 给 g9 发送悄悄话 g9 的博客首页 (137 bytes) () 12/21/2013 postreply 19:57:55

u can get negative number. Same for + and - -inet-fan- 给 inet-fan 发送悄悄话 inet-fan 的博客首页 (0 bytes) () 12/21/2013 postreply 20:59:34

How would you get a negative number? -g9- 给 g9 发送悄悄话 g9 的博客首页 (0 bytes) () 12/21/2013 postreply 21:03:33

A=A XOR B, B= A XOR B, A = A XOR B, done -inet-fan- 给 inet-fan 发送悄悄话 inet-fan 的博客首页 (0 bytes) () 12/21/2013 postreply 20:43:06

不错。是自己搞出来的? -g9- 给 g9 发送悄悄话 g9 的博客首页 (0 bytes) () 12/21/2013 postreply 21:14:29

Come-on. That is an appetizer in interview -inet-fan- 给 inet-fan 发送悄悄话 inet-fan 的博客首页 (140 bytes) () 12/22/2013 postreply 16:40:21

老大,🐂 -wxcmvyanyan- 给 wxcmvyanyan 发送悄悄话 wxcmvyanyan 的博客首页 (0 bytes) () 12/21/2013 postreply 21:36:32

🐂是个啥东东? -inet-fan- 给 inet-fan 发送悄悄话 inet-fan 的博客首页 (0 bytes) () 12/22/2013 postreply 16:46:33

请您先登陆,再发跟帖!

发现Adblock插件

如要继续浏览
请支持本站 请务必在本站关闭/移除任何Adblock

关闭Adblock后 请点击

请参考如何关闭Adblock/Adblock plus

安装Adblock plus用户请点击浏览器图标
选择“Disable on www.wenxuecity.com”

安装Adblock用户请点击图标
选择“don't run on pages on this domain”