473,511 Members | 14,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Signed?


int a;

short b;

long c;

char d;
According to the Standard, are the above signed or unsigned?
-JKop
Jul 22 '05 #1
6 1358
JKop wrote:
int a;

short b;

long c;

char d;
According to the Standard, are the above signed or unsigned?
-JKop


int, short and long are, char is implementation defined.
If you need a signed or unsigned char, use:
signed char
or
unsigned char

- Pete
Jul 22 '05 #2
JKop wrote:
int a;
Yes.
short b;
Yes.
long c;
Yes.
char d;
Maybe (it's implementation dependent).

According to the Standard, are the above signed or unsigned?


HTH,
--ag
--
Artie Gold -- Austin, Texas

"What they accuse you of -- is what they have planned."
Jul 22 '05 #3
Pete C. wrote:
JKop wrote:
int a;

short b;

long c;

char d;
According to the Standard, are the above signed or unsigned?
-JKop
int, short and long are, char is implementation defined.


I mean, int, short and long are signed.

- Pete
If you need a signed or unsigned char, use:
signed char
or
unsigned char

- Pete


Jul 22 '05 #4
JKop wrote:
int a;

short b;

long c;

char d;
According to the Standard, are the above signed or unsigned?
...


Plain 'int', 'short' and 'long' are always equivalent to 'signed int',
'signed short' and 'signed long', unless used to declare a bit-field (in
which case it is implementation-defined whether they are signed or
unsigned).

A plain 'char' is always a separate type, different (as a type) from
both 'signed char' and 'unsigned char'. However, the value range of char
always coincides with value range of either 'signed char' or 'unsigned
char' (which one - implementation defined). Also, the same comment about
bit-fields applies to plain 'char' as well.

--
Best regards,
Andrey Tarasevich

Jul 22 '05 #5
Conforming to the Standard, should the following compile?:
void Garda(signed short int);

int main(void)
{
short p = 4;

Garda(p);
}
void Garda(short frog)
{
frog = 5;
}
Jul 22 '05 #6
JKop wrote:
Conforming to the Standard, should the following compile?:
void Garda(signed short int);

int main(void)
{
short p = 4;

Garda(p);
}
void Garda(short frog)
{
frog = 5;
}


Yes, it should. Both declarations of 'Garda' "[...] agree exactly both
in the type of the value returned and in the number and type of
parameters [...]" (8.3.5/3). Additionally, note in 13.1/3 says that
"[...] function declarations that have equivalent parameter declarations
declare the same function [...]".

--
Best regards,
Andrey Tarasevich

Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
6447
by: MiniDisc_2k2 | last post by:
Okay, here's a question about the standard. What does it say about unsigned/signed mismatches in a comparison statement: char a = 3; unsigned char b = 255; if (a<b) Now what's the real...
8
2221
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
17
7984
by: Christopher Dyken | last post by:
Hi group, I'm trying to implement two routines to handle 32x32-bits and 64x64-bits signed integer multiplication on a 32 bits machine in C. It easy to find descriptions of non-signed...
9
4158
by: dam_fool_2003 | last post by:
For int data type the default range starts from signed to unsigned. If we don't want negative value we can force an unsigned value. The same goes for long also. But I don't understand why we have...
10
15615
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the...
22
5580
by: juanitofoo | last post by:
Hello, I've just switched to gcc 4 and I came across a bunch of warnings that I can't fix. Example: #include <stdio.h> int main() { signed char *p = "Hola";
10
3282
by: =?iso-8859-2?B?SmFuIFJpbmdvuQ==?= | last post by:
Hello everybody, this is my first post to a newsgroup at all. I would like to get some feedback on one proposal I am thinking about: --- begin of proposal --- Proposal to add...
4
4628
by: Chris | last post by:
How do we create digitally signed MDE files in Access 2007 ? I tried to follow the procedure I was using in other office versions. 1. I installed the Verisign certificate (with private key)....
7
5024
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
6
6427
by: Kislay | last post by:
Consider the following code snippet unsigned int i=10; int j= - 2; // minus 2 if(i>j) cout<<"i is greater"; else cout<<"j is greater"; Since i is unsigned , j is greater . I know why , but...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1583
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.