jason christoper hartley

September 21, 2012

Gender Ternary Math

Filed under: Uncategorized — Jason Christopher Hartley @ 10:56 pm
There are two buttons:
  • Female
  • Male
There are three states:
  • FEMALE
  • MALE
  • ID_RATHER_NOT_SAY

A selected button becomes unselected when pressed again.

Let:
  • ID_RATHER_NOT_SAY = 0
  • MALE = 1
  • FEMALE = 2
  • A = current gender
  • B = button pressed
Then:
    gender = Math.abs(A - B) + (A % B);