| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Bitwise |
Hi Simon, SA> SA>> And here's how I'm trying to manipulate it: SA> SA>> m.Attribute&=0x01; SA> SA>> m.Attribute |= 0x02; SA> SA>> m.Attribute &= 0x04; SA> SA>> m.Attribute &= 0x08; SA> SA>> m.Attribute |= 0x10; SA> SA>> m.Attribute &= 0x20; SA> SA>> m.Attribute &= 0x40; SA> SA>> m.Attribute &= 0x80; SA> DN> Each of the above statements "steps on" its predecessor. The result SA> DN> will always be 0x00 in m.Attribute. This is because each operation SA> DN> affects the full byte, not just the bit you are after. SA>Aha! Thanks again David, not just a pretty face. Not even a pretty face... But what a knowledge of programming languages! SA> DN> if (m.Typ == EchoMail) SA> DN> m.Attribute ^= 0x01; /* Toggle bit 0 */ SA> DN> m.Attribute &= 0x01; /* Switch off all except bit 0 (left alone) */ SA> DN> m.Attribute |= 0x12; /* Switch on bits 1 and 4 */ SA> DN> This toggles bit 0 if it is echomail, switches off all other bits and SA> DN> then switches on bits 1 and 4. SA>I /think/ I've got it this time. If not, I'll be back. :) To try to make sure you aren't on this :-). The normal way of doing things is: #define BIT_MASK 0x02 then m.Attribute &= BIT_MASK; /* Switch off eveything _except_ bit */ m.Attribute &= ~BIT_MASK; /* Switch off bit */ m.Attribute |= BIT_MASK; /* Switch on bit */ m.Attribute |= ~BIT_MASK; /* Switch on eveything _except_ bit */ m.Attribute ^= BIT_MASK; /* Toggle bit */ m.Attribute ^= ~BIT_MASK; /* Toggle eveything _except_ bit */ George * SLMR 2.1a * Computers eliminate spare time. --- Maximus/2 3.01* Origin: DoNoR/2,Woking UK (44-1483-717904) (2:440/4) SEEN-BY: 396/1 622/419 632/0 371 633/260 267 270 371 634/397 635/506 728 810 SEEN-BY: 639/252 670/213 218 @PATH: 440/4 255/1 251/25 396/1 633/260 635/506 728 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.