Path: chuka.playstation.co.uk!news1.scei.co.jp!scea!greg_labrec@interactive.sony.com From: mperdue@iquest.net (Mario Perdue) Newsgroups: scea.yaroze.programming.2d_graphics Subject: Re: How do I set attributes? Date: Wed, 30 Apr 1997 03:36:12 GMT Organization: SCEA Net Yaroze News Lines: 33 Message-ID: <3366bbbe.47338581@205.149.189.29> References: <01bc5507$4e667200$7d73d9ce@mannynaj> NNTP-Posting-Host: ind-0007-21.iquest.net X-Newsreader: Forte Free Agent 1.1/32.230 Manny, It's really pretty simple to set bits in a field. Here's what you do: To set the (i.e. make it a 1) you OR the bits you want set with the original data. Suppose you have a variable called attribute, and you want to set bit 3 (counting from 0, that would be the fourth bit.) Here's what you do: attribute |= 0x0008; To clear the bit (i.e. make it 0) you AND the compliment of the bits you want set with the original data, like this: attribute &= 0xFFF7; These examples are for 16 bits, but it works the same for 32 bits or any other number of bits for that matter. You could also define a bit-mapped field and reference each bit by name, but that would make your code less portable. Mario On 30 Apr 1997 01:37:23 GMT, "Manny Najera" wrote: >I'm not too keen on how to set induvidual bits in a 32 bit number, can >someone show me how this is done? > >Manny Najera