 # uint8_t and BIN

uint8_t data;

i need get value from data as BIN ( 67 bit )

You need to get 67 bit data from a 128 bit data set?

8 bits.

Oops.

igorvukotic:
i need get value from data as BIN ( 67 bit )

I’m not sure that is possible. Why do you want to?

http://xyproblem.info/

i have 128 BITs, so i need to evalute 67 BIT state.... ( only one bit )

igorvukotic: i have 128 BITs, so i need to evalute 67 BIT state.... ( only one bit )

Nope, still not getting it.

HEX 00 00 03 90 84 30 65 45 2B 80 00 00 00 00 00 00

BIN 00000000000000000000000000000011000010010000000010000100000000110{0}0000000110010100000100010100000010101100001000000000000000000000000000000000000000000000000000000000000000000000000000

evalute BIT state in {}

You probably want to use the division ('/') and modulo ('%') operators to locate the correct byte and bit, and then use bitRead to get the value of the bit you're interested in.

My BitBool library makes this fairly simple. http://forum.arduino.cc/index.php?topic=128407.0

There are a few ways of doing what you want, here is one:

``````#include <BitBool.h>

uint8_t data;

typedef BitBool< 128 > BITS;

void setup() {
BITS &bits = *(BITS*) data;

bool bitValue = bits[ 67 ];
}

void loop() {}
``````
``````uint8_t data;
``````

Gives you 16 8 bit values, or 128 bits Bit 67 of the whole array is bit 4 of data so to read it you can use

``````bitRead(data, 4);
``````

igorvukotic: HEX 00 00 03 90 84 30 65 45 2B 80 00 00 00 00 00 00

BIN 00000000000000000000000000000011000010010000000010000100000000110{0}0000000110010100000100010100000010101100001000000000000000000000000000000000000000000000000000000000000000000000000000

evalute BIT state in {}

I don't understand this either. What does evaluate mean? Look, tell us what you are trying to solve, not how you want to evaluate bits.

http://xyproblem.info/

Thanks pYro_65 & UKHeliBob Thats exactly what i need