# Bit from Binary

## Recommended Posts

Is there any function to extract bit from Binary?

i need someting like that

0123456701234567012345670123456701234567

0110001111000111110001111100000000100100

Loooking for 29 bits starting at bit 6

I have some idea

First extract the first byte of the binary

\$Byte1 = BinaryMid( \$Var, 1, 1 )

Second, AndIt to remove the first X not wanting byte

\$Byte1 = BitAnd( \$Byte1 AND "11111100" ) ok not working but i use binary for clarity

This add non significatif 0 at start of the number

But i dont have any idea to remove the signifiant bit at end of the number

BitShift should be the solution but i dont think it work with biger than 32 bits value?

Stéphane

##### Share on other sites

This is wrong:

\$Byte1 = BitAnd( \$Byte1 AND "11111100" )

Its either:

\$Byte1 = BitAnd( \$Byte1,"11111100" )

-or-

\$Byte1 = \$Byte1 AND "11111100"

##### Share on other sites

You are confused, and so your post is confusing as well.

Assuming that you have

\$a = "0110001111000111110001111100000000100100"

\$b = StringMid(\$a, 7, 30)

##### Share on other sites

You are confused, and so your post is confusing as well.

Assuming that you have

\$a = "0110001111000111110001111100000000100100"

\$b = StringMid(\$a, 7, 30)

ok i see, i have a Binary data, who contain value and the binary representation of the data is "0110001111000111110001111100000000100100" in need to extract Bit from the midle of this bitfield but its contain into Bytes.

This is not easy to explain

Stéphane

## Create an account

Register a new account

×

• Wiki

• Back

• Git