# supplied code giving incorrect instructions

I bet someone a long time ago pointed this out but I would like to draw your attention to the code for shift registers
this one
It clearly states
//Arduino doesn't seem to have a way to write binary straight into the code

I am sure the whole of the array

``````   dataArrayRED[0] = 0xFF; //11111111
dataArrayRED[1] = 0xFE; //11111110
dataArrayRED[2] = 0xFC; //11111100
dataArrayRED[3] = 0xF8; //11111000
dataArrayRED[4] = 0xF0; //11110000
dataArrayRED[5] = 0xE0; //11100000
dataArrayRED[6] = 0xC0; //11000000
dataArrayRED[7] = 0x80; //10000000
dataArrayRED[8] = 0x00; //00000000
dataArrayRED[9] = 0xE0; //11100000
``````

could be changed to
dataArrayRED = {B11111111,B11111110,B11111100,B11111000,B11110000,B11100000,B11000000,B10000000,B00000000,B11100000};

or even
dataArrayRED =
{B11111111
,B11111110
,B11111100
,B11111000
,B11110000
,B11100000
,B11000000
,B10000000
,B00000000
,B11100000};

Using the capital B to "write binary straight into the code".

Is it possible to add this fact into the code?

One could also use the C++ 0b00001111 type of format.
Works for ints and longs as well, where B00001111 is only defined for bytes I believe.
0x0F is less typing tho and what most engineers would use unless 0b00001111 is used for clarity of bit manipulation, such as
PORTD = PORT & 0b11111011; // clear D2
PORTD = PORTD | 0b00000100; // set D2

The comment could have been

``````[pre][ltr]// Date : 25 Oct, 2006 //
// add Bxxxxxxxx format for definitions? or teach folks to use 0bxxxxxxxx and 0xFF.
// lets waffle on that for a while ...

//Arduino doesn't seem to have a way to write binary straight into the code
``````

I think in this case binary notation is more clear. It’s old code (2006) but the Arduino core did have binary.h at that time, I guess the authors didn’t know about that. The 0b binary prefix wasn’t added to GCC until 2007 and it was probably a while after that before it made it to the Arduino toolchain:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23479