Total NOOB programming question...

For makers who have purchased an Adafruit Starter Pack, get help with the tutorials here!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
chuggins143
 
Posts: 2
Joined: Fri Feb 19, 2010 6:58 pm

Total NOOB programming question...

Post by chuggins143 »

Ok, I'm working through the tutorials (http://www.ladyada.net/learn/arduino/lesson4.html) and am on the 4th one and have a question that I'm not finding a answer for... How are signed and unsigned types indicated? ...I'm looking at the code provided and I'm not seeing any difference.
TIA, for the help understanding!
Chad

User avatar
jamesm
 
Posts: 41
Joined: Wed Aug 12, 2009 11:42 pm

Re: Total NOOB programming question...

Post by jamesm »

There are "signed" and "unsigned" keywords in C++ (which the Arduino uses).

So if you want to keep track of a value between 0 and 255, you could do this:

Code: Select all

unsigned char value;
Most types default to signed, so for example these do the same thing:

Code: Select all

signed int example;   // These are the same type
int example2;   
The special case is the "char" type. The language standard does not specify if a "char" is signed or unsigned, so you should be explicit about it if you care.

Does that answer your question?

chuggins143
 
Posts: 2
Joined: Fri Feb 19, 2010 6:58 pm

Re: Total NOOB programming question...

Post by chuggins143 »

Yes it does, 100%... The tutorial explained that most types were default to signed, but none of the examples I was working with had an example of the unsigned nomenclature used in code so I had no reference by which to base an assumption off of.
Thank you!
Chad

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Starter Pack”