range of char

  • Thread starter Wolfgang Jeltsch
  • Start date
W

Wolfgang Jeltsch

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
 
W

WW

Wolfgang said:
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.
 
T

tom_usenet

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
 
R

Ron Natalie

Wolfgang Jeltsch said:
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.
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top