Is the Integer formatter BINARY not implemented?

Note but looks documented as an example:
See Compound operators; for instance &=(compound bitwise and)

The following code gives errors;
————————
static unsigned short receivedBit;
void setup() {
receivedBit = receivedBit & B1111;
}

void loop() {

}
————
After verification

In file included from …/inc/spark_wiring.h:30:0,
from …/inc/application.h:29,
from test.cpp:2:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
#warning “Defaulting to Release Build”
^
test.cpp: In function ‘void setup()’:
test.cpp:3:29: error: ‘B1111’ was not declared in this scope
void setup();
^
make: *** [test.o] Error 1

Error: Could not compile. Please review your code.

On a spark it’s 0b instead of B

Thanks for the info, but the doc is unclear about that
Robert

Did it work for you using the 0b1111? I see what you mean about the doc’s site saying B11110101 in the bitwise and… I don’t know

Yes it is working now, thanks.
… I beleive the doc a cut/paste of the arduino one :slight_smile:

Thanks @rrobinet1 and @Hootie81!

I will test this and send a PR to fix the wrong example afterwards. :wink:

1 Like

Hi @kennethlimcp
It may be good to add to the doc a description of the integer constants as for Adruino; see:
http://arduino.cc/en/Reference/IntegerConstants

Robert

I have opened an issue for this: https://github.com/spark/core-firmware/issues/273