Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Datatypes

Reply
Thread Tools

Datatypes

 
 
anjna22@gmail.com
Guest
Posts: n/a
 
      05-15-2007
if we simply write "char" or "int" , it is "signed char" or "signed
int".

but in some compiler we have to write explicitly "signed int ", why is
it so.

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      05-15-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> if we simply write "char" or "int" , it is "signed char" or "signed
> int".
>

No, signed char and char are distinct types.

> but in some compiler we have to write explicitly "signed int ", why is
> it so.
>

Name one.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      05-15-2007
In article <(E-Mail Removed) om>,
<(E-Mail Removed)> wrote:

>if we simply write "char" or "int" , it is "signed char" or "signed
>int".
>
>but in some compiler we have to write explicitly "signed int ", why is
>it so.


No, plain char can be signed or unsigned, but plain int is always
signed. You might have to write signed char if you want a small
signed variable, but you never have to write signed int.

-- Richafrd



--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
Keith Halligan
Guest
Posts: n/a
 
      05-15-2007
On May 15, 11:09 am, (E-Mail Removed) wrote:
> if we simply write "char" or "int" , it is "signed char" or "signed
> int".


If you write "char", then it will generally have -128 <---> +127, A
signed char will have all negative values, up to -255. The similar is
true for int as well.

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-15-2007
Richard Tobin said:

> In article <(E-Mail Removed) om>,
> <(E-Mail Removed)> wrote:
>
>>if we simply write "char" or "int" , it is "signed char" or "signed
>>int".
>>
>>but in some compiler we have to write explicitly "signed int ", why is
>>it so.

>
> No, plain char can be signed or unsigned, but plain int is always
> signed. You might have to write signed char if you want a small
> signed variable, but you never have to write signed int.


....except in bitfields.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-15-2007
Keith Halligan said:

> On May 15, 11:09 am, (E-Mail Removed) wrote:
>> if we simply write "char" or "int" , it is "signed char" or "signed
>> int".

>
> If you write "char", then it will generally have -128 <---> +127,


Generally, maybe, but not guaranteed.

On systems where plain char is signed by default (typical PCs), the
guarantee is -127 to +127. On systems where it is unsigned by default
(typical mainframes), the guarantee is 0 to 255.

> A signed char will have all negative values, up to -255.


On a system where CHAR_BIT is 9, maybe - but of course it must also have
a corresponding number of positive values and at least one zero value.
More generally, a signed char will be able to represent all values in
the range SCHAR_MIN to SCHAR_MAX.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
anjna22@gmail.com
Guest
Posts: n/a
 
      05-15-2007
On May 15, 3:14 pm, Ian Collins <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > if we simply write "char" or "int" , it is "signed char" or "signed
> > int".

>
> No, signed char and char are distinct types.
>
> > but in some compiler we have to write explicitly "signed int ", why is
> > it so.

>
> Name one.
>
> --
> Ian Collins.


Can anyone explain difference between char , signed dhar

 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      05-15-2007
(E-Mail Removed) said:

>
> Can anyone explain difference between char , signed dhar


signed char, presumably.

Okay: signed char is a signed integer type, unsigned char is an unsigned
integer type, and whether char is a signed integer type or an unsigned
integer type is entirely up to the implementation, but it must document
its choice.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
 
Reply With Quote
 
Joachim Schmitz
Guest
Posts: n/a
 
      05-15-2007
<(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) oups.com...
> On May 15, 3:14 pm, Ian Collins <(E-Mail Removed)> wrote:
>> (E-Mail Removed) wrote:
>> > if we simply write "char" or "int" , it is "signed char" or "signed
>> > int".

>>
>> No, signed char and char are distinct types.
>>
>> > but in some compiler we have to write explicitly "signed int ", why is
>> > it so.

>>
>> Name one.
>>
>> --
>> Ian Collins.

>
> Can anyone explain difference between char , signed dhar

char is implementation defined either signed or unsigned, check your
compiler's documantation
signed dhar is a typo... OK, just kidding: signed char is just that, at
least 8 bits wide and signed.
On some system they are different, on others they are the same.

Bye, Jojo


 
Reply With Quote
 
Chris Dollin
Guest
Posts: n/a
 
      05-15-2007
Keith Halligan wrote:

> On May 15, 11:09 am, (E-Mail Removed) wrote:
>> if we simply write "char" or "int" , it is "signed char" or "signed
>> int".

>
> If you write "char", then it will generally have -128 <---> +127,


That depends on the implementation. Unmarked char can be represented
as [note: /not/ the same /type/ as] either signed char or unsigned
char, at the convenience of the implementation -- which probably
depends on what its underlying machine does on load-byte instructions.

> A signed char will have all negative values, up to -255.


Not on almost all existing machines, it won't, since that would leave
no room for the C character set, whose elements are positive whatever
the signedness of char.

> The similar is true for int as well.


That depends on what degree of similarity you choose.

--
Is it a bird? It is a plane? No, it's: http://hpl.hp.com/conferences/juc2007/
WARNING. Various parts of this product may be more than one billion years old.

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
complex datatypes in webservices. Ashish ASP .Net 1 12-19-2005 07:51 PM
text box and SqlDecimal datatypes Mark ASP .Net 2 11-07-2005 05:34 PM
Specified cast not valid on decimal & double datatypes .Net Sports ASP .Net 1 08-31-2005 09:11 AM
Problem while reading excel file with mix datatypes =?Utf-8?B?UGF1cmF2aQ==?= ASP .Net 1 03-04-2004 03:11 AM
interrogating database for field names/datatypes? ASP .Net 2 07-28-2003 01:39 AM



Advertisments