i am running this sketch to play around with signed and unsigned variables.
Code: Select all
/*
* Hello World!
*
* This is the Hello World! for Arduino.
* It shows how to send data to the computer
*/
byte num = 126;
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.print("You Started with: ");
Serial.println(num); // prints hello with ending line break
Serial.print("Now you have: ");
Serial.println(num - 128);
}
void loop() // run over and over again
{
// do nothing!
}
It looks like this
Code: Select all
You Started with: ~
Now you have: -2
if i change it to int then it displays fine but i didn't want an int or i would have made it that in the first place.
I would greatly appriciate any help that anyone could give me, whether it be directions on how to fix this or why it happens this way.