functions bitRead(x,n) and bitWrite((x,n,b)

Using Rev 16 - functions bitRead(x,n) and bitWrite(x,n,b)
does not work on data type float.

float z = 3.134
Compile error on using bitRead(z,0) = error: invalid operands of types 'float' and 'int' to binary 'operator>>'

Note: compiles fine on long data type
:frowning: :frowning: :frowning:

What were you expecting to happen?

AFAIK bit manipulations are limited to integers.

--Phil.

Edit: It's helpful if you don't cross-post and/or if you do, link the two threads together so people don't waste time answering questions that have already been answered.

Quote: "AFAIK bit manipulations are limited to integers"

For some reason, the bit routines did compile on a long data type.
I have not yet checked if the logic worked correctly.

I was expecting, since the data type float was not in the standard
IEEE 754 format used by most computers, that I could bit read the 32 bits, convert them to 4 bytes for data transmission. Having to transfer chars in a non fixed format throws a monkey wrench in my packet transmission to another Arduino. :frowning: :frowning: :frowning:

For some reason, the bit routines did compile on a long data type.

The long is actually a long int :slight_smile:

was expecting, since the data type float was not in the standard
IEEE 754 format used by most computers, that I could bit read the 32 bits, convert them to 4 bytes for data transmission. Having to transfer chars in a non fixed format throws a monkey wrench in my packet transmission to another Arduino.

The "float" type on the Arduino is IEEE-754.

I don't know why you would have wanted to do bit-manipulation on the "float" type anyway - just cast a char pointer to the address of your float and read out the bytes that way. To do it bit-by-bit is just going to be slow.