PDA

Click to See Complete Forum and Search --> : Bit Stuff


Vlatko
Nov 20th, 2000, 03:31 PM
I have a DWORD variable and i want to know the value of the least significant bit and the one next to him .How can i acomplish this.
Thanks!

parksie
Nov 20th, 2000, 03:36 PM
unsigned long x = 0xffffffff;

unsigned char y = x & 0x1;
// or (depends on architecture)
unsigned char y = x & 0x80000000;

Depending on whether the compiler decides to do any playing around with your endians (as it were)...

[Edited by parksie on 11-20-2000 at 04:40 PM]

HarryW
Nov 20th, 2000, 05:20 PM
This ought to work, oughtn't it? (is that even a word?)


y = your_variable;
y <<= 31;
y >>= 31;