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
Total NOOB programming question...
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- jamesm
- Posts: 41
- Joined: Wed Aug 12, 2009 11:42 pm
Re: Total NOOB programming question...
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:
Most types default to signed, so for example these do the same thing:
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?
So if you want to keep track of a value between 0 and 255, you could do this:
Code: Select all
unsigned char value;
Code: Select all
signed int example; // These are the same type
int example2;
Does that answer your question?
-
- Posts: 2
- Joined: Fri Feb 19, 2010 6:58 pm
Re: Total NOOB programming question...
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
Thank you!
Chad
Please be positive and constructive with your questions and comments.