Logical Question

From RoboWiki
Jump to: navigation, search
Revision as of 25 June 2013 at 19:29.
The [/w/index.php?title=User_talk:Sheldor&offset=20130625192926&lqt_mustshow=3526 highlighted comment] was created in this revision.

Is there any kind of bit operation or arithmetical trick that would allow me to do something like integerWhichCouldOnlyHaveAValueOfZeroOrOne == 0 ? otherIntegerWhichCouldOnlyHaveAValueOfZeroOrOne == 0 ? 0 : 1 : 2 without so many expensive conditionals?

    Sheldor (talk)15:20, 25 June 2013

    Like this?

    integerWhichCouldOnlyHaveAValueOfZeroOrOne | otherIntegerWhichCouldOnlyHaveAValueOfZeroOrOne + integerWhichCouldOnlyHaveAValueOfZeroOrOne

      MN (talk)17:02, 25 June 2013

      Yes, I think that would work.

      Thanks

        Sheldor (talk)17:58, 25 June 2013
         

        If there is no possibility that integerWhichCouldOnlyHaveAValueOfZeroOrOne == 1 and otherIntegerWhichCouldOnlyHaveAValueOfZeroOrOne == 0, or if you don't care, then a simple addition would work.

          Skilgannon (talk)18:59, 25 June 2013

          There is a chance that the first and second integers would add up to 1 in two different scenarios. I do care to avoid this because I was planning to use this in VCS segmentation. It would not be prudent to represent two very different situations by the same segment.

            Sheldor (talk)19:29, 25 June 2013
             
             
            Personal tools