Logical Question

Jump to navigation Jump to search
Revision as of 25 June 2013 at 18:59.
The highlighted comment was created in this revision.

Logical Question

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)17:20, 25 June 2013

    Like this?

    integerWhichCouldOnlyHaveAValueOfZeroOrOne | otherIntegerWhichCouldOnlyHaveAValueOfZeroOrOne + integerWhichCouldOnlyHaveAValueOfZeroOrOne

      MN (talk)19:02, 25 June 2013

      Yes, I think that would work.

      Thanks

        Sheldor (talk)19: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)20:59, 25 June 2013