
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
> Ganz dumme Frage: > > Ich hab eine byte Variable. Zu der brauche ich das passende Parity-Bit (Gerade) > Wie komme ich möglichst ohne viel Rechenzeit an diesen Wert ? > > Gruß, > Markus Hallo, ich würde eine der folgenden Lösungen nehmen. Für Basic++ sinngemäß MfG ManfredW define Testbyte byte define parity Bit [ ] define Bits byte 'Bit0 bis Bit7 define Bit0 Bit [ ] define Bit1 Bit [ ] usw. 1. Möglichkeit Bits = Testbyte Parity = ON 'Vorbesetzung even if Bit0 then Parity = not Parity if Bit1 then Parity = not Parity if Bit2 then Parity = not Parity if Bit3 then Parity = not Parity if Bit4 then Parity = not Parity if Bit5 then Parity = not Parity if Bit6 then Parity = not Parity if Bit7 then Parity = not Parity '-------------------------------- 2. Möglichkeit (vermutlich schneller) Bits = Testbyte Parity = ON 'Vorbesetzung even Parity = Bit0 XOR Parity Parity = Bit1 XOR Parity Parity = Bit2 XOR Parity Parity = Bit3 XOR Parity Parity = Bit4 XOR Parity Parity = Bit5 XOR Parity Parity = Bit6 XOR Parity Parity = Bit7 XOR Parity ' 01 11 00 10 ' Beispiel Bit7 Parity = 1 0 0 1 Meine Homepage: http://manfred.wilzeck.de |
| Antwort schreiben |