Convert 0 to 1 and Vice Versa

Posted by javaguy on Stack Overflow See other posts from Stack Overflow or by javaguy
Published on 2010-05-06T22:37:31Z Indexed on 2010/05/06 22:38 UTC
Read the original article Hit count: 218

I was asked in an interview : how to convert 0 to 1 and 1 to 0. I answered :

  1. Simple if and switch
  2. Bit flipping.

Are there any other approach?

© Stack Overflow or respective owner

Related posts about java

Related posts about language-agnostic