What is the best way to take an incoming byte value of 0x01 and change it to 0xFFFFFF81?
taking 0xFFFFFF80 ^(xor) 0x01 works.
regular OR would work also:
incomingByte = incomingByte | 0xFFFFFF80
or add to it:
incomingByte = incomingByte + 0xFFFFFF80
What is it you're trying to do?
What is the best way to take an incoming byte value of 0x01 and change it to 0xFFFFFF81?
a (incoming) byte value cannot be changed to 0xFFFFFF81. You need a (unsigned) long to hold such a large number.
If you have an incoming long you should use
switch(incoming)
{
case 0x01 : incoming = 0xFFFFFF81; break;
// add aditional values to process.
}
The examples mentioned before will work if the incoming value is restricted to 0 and 1 but have side effects when the incoming value is larger than 0x01, e.g. 0x37
Mavromatis:
What is the best way to take an incoming byte value of 0x01 and change it to 0xFFFFFF81?
Yeah, it would be helpful to have more context. Right now, I would say the answer to this question is...
if ( value == 1 )
value = 0xffffff81;