longnegative_var=-0;//
unsignedlonglongpositive_var=0;//predefined sizes when looping through bits
//e.g. long_size is 32 bit (which is 0-31). Therefore, we subtract "1".
constintbool_size=(1-1);constintint_size=(8-1);constintlong_size=(32-1);voidsetup(){Serial.begin(9600);}voidloop(){//run readBit function, passing the pos/neg variables
readBit("Positive ",positive_var);readBit("Negative ",negative_var);Serial.println();//increase and decrease the variables
negative_var--;positive_var++;delay(1000);}/*this function takes a variable, prints it out bit by bit (starting from the right)
then prints the decimal number for comparison.*/voidreadBit(Stringdirection,longcounter){Serial.print(direction+"Binary Number: ");//loop through each bit
for(intb=long_size;b>=0;b--){bytebit=bitRead(counter,b);Serial.print(bit);}Serial.print(" Decimal Number: ");Serial.println(counter);}