Advertisement

unsigned????

Started by January 18, 2002 05:55 AM
3 comments, last by elis-cool 22 years, 9 months ago
The auther of C++ for dummies has introduced the keyword ''unsigned'' and he doesn''t even explain it in the book anywhere! What does this mean? eg. unsigned var; unsigned float var; He also introduced ''const'' but I can gather what that means.
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
Normal variables are signed, this means that one bit on the variable is used to determine whether the variable is positive or negative. If you use an unisgned variable, you cannot have negative numbers, but the highest positive number is doubled.

eg.
int my_int; // min = -2147483648 max = 2147483648
signed my_int; // as signed int (variables are implicitly signed)
unsigned int my_int; // min = 0 max = 4294967296
Advertisement
Const is analogous to a variable, except that it''s value is initialized at declaration and can never change! You want to do this often with string constants and such. it is a value that will always be the same and that you need to be accessible, but you want to make sure it is not accidentally changed, thereby screwing your prog up.

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
As a note: you can''t have an unsigned floating point variable.

[Resist Windows XP''s Invasive Production Activation Technology!]
thanks for the help!
[email=esheppard@gmail.com]esheppard@gmail.com[/email]

This topic is closed to new replies.

Advertisement