Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > range of char

Reply
Thread Tools

range of char

 
 
Wolfgang Jeltsch
Guest
Posts: n/a
 
      10-03-2003
Hello,

what does the ANSI C++ standard say about the minimal range of the char
type? Is it guaranteed that char contains at least the numbers from 0 to
255?

Thanks a lot.

Wolfgang
 
Reply With Quote
 
 
 
 
WW
Guest
Posts: n/a
 
      10-03-2003
Wolfgang Jeltsch wrote:
> Hello,
>
> what does the ANSI C++ standard say about the minimal range of the
> char type? Is it guaranteed that char contains at least the numbers
> from 0 to 255?


Nope. It is implementation defined if char is signed or not. And yes, it
is guaranteed to have at least 8 bits, and all of its bits must be used in
the value representation.

--
WW aka Attila


 
Reply With Quote
 
 
 
 
Buster
Guest
Posts: n/a
 
      10-03-2003
"Wolfgang Jeltsch" <> wrote

> what does the ANSI C++ standard say about the minimal range of the char
> type? Is it guaranteed that char contains at least the numbers from 0 to
> 255?


The C++ standard ISO/IEC 14882:1998 is available from the ISO online
shop, http://www.iso.ch/iso/en/prods-servi...ore/store.html, for
US$18, and worth every penny.

Regards,
Buster.


 
Reply With Quote
 
tom_usenet
Guest
Posts: n/a
 
      10-03-2003
On Fri, 03 Oct 2003 19:28:07 +0200, Wolfgang Jeltsch
<> wrote:

>Hello,
>
>what does the ANSI C++ standard say about the minimal range of the char
>type? Is it guaranteed that char contains at least the numbers from 0 to
>255?


On many platforms, including IIRC MSVC++, it has the range [-128, 127]
- remember, it can represent the same values as either signed or
unsigned char. However, unsigned char does have at least that range,
since it much have 8-bits or more, and every bit pattern must
represent a unique number (due to the modulo arithmetic rules).

Tom
 
Reply With Quote
 
Ron Natalie
Guest
Posts: n/a
 
      10-03-2003

"Wolfgang Jeltsch" <> wrote in message news:blkbau$d2644$...
> Hello,
>
> what does the ANSI C++ standard say about the minimal range of the char
> type? Is it guaranteed that char contains at least the numbers from 0 to
> 255?


Absoltutely not. unsigned char has to do at least 0...255, but char can
either be signed or unsigned.


 
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
IE Selection/Range: Set range start at the click position, get char offset adamjroth@gmail.com Javascript 2 04-09-2007 04:02 AM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
The difference between char a[6] and char *p=new char[6] ? wwj C Programming 24 11-07-2003 05:27 PM
the difference between char a[6] and char *p=new char[6] . wwj C++ 7 11-05-2003 12:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57