Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In the accompanying video[0] at 7:36 mark, he goes to great lengths to express (A or B) as (A and B) + (A xor B).

Can anybody explain why it can't simply be expressed as (A and B) xor (A xor B)? What am I missing here?

0. https://www.youtube.com/embed/LA_DrBwkiJA



Whether you add or xor will make no difference since there will never be two bits set in the same position. The key point is that printable ASCII limits what operations are available, so you have to synthesize some of them.


The difference is that xor is available to him (he mentions that in the video), while addition needs to be achieved by combining multiple instructions.


it can, as was discussed in comments on the video with replies from Tom. IIRC, the source code has been updated to use that instead.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: