SOLVED: Problems with "bitwsie not"

I use a LEDbar (8LED’s). I calculate a byte for the status, but for the LEDcontrol I have to send the inverters bits tot a I2C driver.

Something strange:
temperaly = 11101110 (8 bits)
~temperaly = 11111111111111111111111100010001 (32 bits).

Version: Arduino 1.6.1 (in the former version ~temperaly worked correct)

// Wire Master Writer
// by Nicholas Zambetti http://www.zambetti.com

// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the “Wire Slave Receiver” example for use with this
// Created 29 March 2006
// This example code is in the public domain.

#include <Wire.h>
byte LED[8];

void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); //Enables printing to serial monitor
}

byte x = 0;

void loop()
{
byte temporaly;
Wire.beginTransmission(0x38); // transmit to device PCF8574A, A1=A2=A3=0, adres Ox38 of 56 dec

LED[1]=0;
LED[2]=1;
LED[3]=1;
LED[4]=1;
Serial.println(“Dit is een test”); Serial.println("");
LED[5]=0;
LED[6]=1;
LED[7]=1;
LED[8]=1;
temporaly=128LED[8]+64LED[7]+32LED[6]+16LED[5]+8LED[4]+4LED[3]+2*LED[2]+LED[1];

//Send text to serial display
Serial.print(temporaly,BIN);Serial.println("");
Serial.print (~temporaly,BIN);Serial.println("");

//Send byte to I2Cport
//Wire.write(~temporaly);
Wire.write(temporaly); //Write temporaly to I2C line (=LEDs)

Wire.endTransmission(); // stop transmitting
delay(250);
}
//Als x=0 branden alle LED’s, als x=0xFF (=127) zijn alle LED’s uit

Is this on a 32 bit processor like the Due, by any chance? ~ inverts all the bits and remember expressions always widen to the width of the int type unless you cast them back to byte. Passing a value to Serial.print is always going to widen the argument to int.

Using print on a byte or int will get printed as a long.

From Print.cpp

size_t Print::print(unsigned char b, int base)
{
  return print((unsigned long) b, base);
}

size_t Print::print(int n, int base)
{
  return print((long) n, base);
}

size_t Print::print(unsigned int n, int base)
{
  return print((unsigned long) n, base);
}

Thanks for the feedback.

To eliminate only the 8 least significant bits I use now: Wire.write(~temporaly & 0xFF);

What kinds of things is bitwise not used for?

I understand it makes a zero a one and vise versa, but why would you want to do it?

Does i2c only accept inverted bits?

What kinds of things is bitwise not used for?

Google "de Morgan"