unsigned without type (Newbie)

S

Sting

Hello ,
I have a short simple question:
what is unsigned without a type?

like unsigned varname ?

is it unsigned int, unsigned char ,
unsigned long,
etc?
regards,
sting
 
N

Nejat AYDIN

Sting said:
Hello ,
I have a short simple question:
what is unsigned without a type?

like unsigned varname ?

it is equivalent to "unsigned int varname"
 
R

Robert W Hand

like unsigned varname ?

is it unsigned int, unsigned char ,
unsigned long,

unsigned varname;

varname is of type unsigned int. There is no ambiguity. The unsigned
integer types (C99) are:

unsigned char var1;
unsigned short var2;
unsigned short int var3;
unsigned long var4;
unsigned var5;
unsigned int var6;
unsigned long int var7;
unsigned long long var8;
unsigned long long int var9;

Note that several types have multiple ways to declare a variable.
HTH.

Best wishes,

Bob
 
D

Dan Pop

In said:
I have a short simple question:
what is unsigned without a type?

like unsigned varname ?

is it unsigned int, unsigned char ,
unsigned long,
etc?

With the exception of character types, all the integer types
contain an implied int in their names.
Here's the complete list of C89 type aliases:

* short, signed short, short int, or signed short int
* unsigned short, or unsigned short int
* int, signed, signed int, or no type specifiers
* unsigned, or unsigned int
* long, signed long, long int, or signed long int
* unsigned long, or unsigned long int

Dan
 
J

Jack Klein

unsigned varname;

varname is of type unsigned int. There is no ambiguity. The unsigned
integer types (C99) are:

unsigned char var1;
unsigned short var2;
unsigned short int var3;
unsigned long var4;
unsigned var5;
unsigned int var6;
unsigned long int var7;
unsigned long long var8;
unsigned long long int var9;

Note that several types have multiple ways to declare a variable.
HTH.

Best wishes,

Bob

You forgot one:

"The type _Bool and the unsigned integer types that correspond to the
standard signed integer types are the standard unsigned integer
types."

6.2.5 paragraph 6.

_Bool is an unsigned type.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
J

Jack Klein

... which leads to the seeming paradox:

No sign of a _Bool anywhere. :)

-Mike

It has some interesting side effects, perhaps not intended by the
committee, that the C++ bool type does not.

Consider:

_Bool /* just plain bool if <stdbool.h> included */ my_bool;

/* once my_bool is given an initial value... */

--my_bool;

....always toggles from true to false or vice versa.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
K

Kevin Bracey

In message <[email protected]>
Jack Klein said:
It has some interesting side effects, perhaps not intended by the
committee, that the C++ bool type does not.

Consider:

_Bool /* just plain bool if <stdbool.h> included */ my_bool;

/* once my_bool is given an initial value... */

--my_bool;

...always toggles from true to false or vice versa.

Indeed, but that's nothing to do with being an unsigned type, as far as I can
see. It's just because --x is defined as being equivalent to "(x-=1)".

That means we calculate the expression "my_bool-1", in which the value of
my_bool gets promoted to an int, leading to the (int) result -1 or 0. This
then gets converted back on assignment to the _Bool to 1 and 0 respectively.

I don't see why C++ outlawed the use of -- on bool myself. Coming from the
language that decided to use >> for output, it seems a little rich.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top