simply i am having long values i want to extract required data..what is best way to do it?
0013173896 110010010000010010001000
529664272 11111100100100000100100010000
need to extract 0013173896 from 529664272..
simply i am having long values i want to extract required data..what is best way to do it?
0013173896 110010010000010010001000
529664272 11111100100100000100100010000
need to extract 0013173896 from 529664272..
extract = (data >> 1) & 0xFFFFFF;
@OP
Can you please clarify a little bit of your requirements?
integer-decimal 0013173896 is equivalent to binary 110010010000010010001000
integer-decimal 529664272 is equivalent to binary 11111100100100000100100010000
When you say that you want to extract 0013173896 from 529664272. What have you wanted to mean by saying extraction?
Do you want to say that 0013173896 is within 529664272, and you want to bring it out?
these are the wiegand code format outputs..actual data starts from 16th bit and last parity bit is excluded
If the omitted bit positions are consistent, re-read #1.
Shifting 529664272 >> 1 will drop the rightmost bit, & 0xFFFFFF will then filter the next 24 rightmost bits, effectively dropping the leftmost 4.
void setup()
{
Serial.begin(9600);
uint32_t num = 529664272 ; //11111100100100000100100010000
num = naum >>1; //1111110010010000010010001000
num = num & 0xFFFFFF; //110010010000010010001000
Serial.println(num, BIN); //prints: 110010010000010010001000
Serial.print(num, DEC); //prints: 13173896
}
void loop()
{
}