Shop OBEX P1 Docs P2 Docs Learn Events
Parity and spin — Parallax Forums

Parity and spin

Marc GebauerMarc Gebauer Posts: 60
edited 2007-01-21 21:22 in Propeller 1
Does anyone know the·fastest way to calculate odd parity in spin?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • asterickasterick Posts: 158
    edited 2007-01-21 18:58
    PUB Parity(a) : p
      p := (a >> 16) ^ a
      p ^= p >> 8
      p ^= p >> 4
      p ^= p >> 2
      p &= 1
    
    
  • Marc GebauerMarc Gebauer Posts: 60
    edited 2007-01-21 20:01
    Works! Thanks alot!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • asterickasterick Posts: 158
    edited 2007-01-21 21:22
    Marc Gebauer said...
    Works! Thanks alot!

    I forgot a p ^= p >> 1

    you may want to put that after the p ^= p >> 2, otherwise you won't get a perfect parity.
Sign In or Register to comment.