473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

range of char

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
Jul 19 '05 #1
4 8052
WW
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
Jul 19 '05 #2
"Wolfgang Jeltsch" <je*****@tu-cottbus.de> 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.
Jul 19 '05 #3
On Fri, 03 Oct 2003 19:28:07 +0200, Wolfgang Jeltsch
<je*****@tu-cottbus.de> 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
Jul 19 '05 #4

"Wolfgang Jeltsch" <je*****@tu-cottbus.de> wrote in message news:bl************@ID-77306.news.uni-berlin.de...
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.
Jul 19 '05 #5

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

Similar topics

3
by: aroy | last post by:
Hi, Need help in optimizing a query in SQL Server. Following is the problem statement. There are two tables; 1st table (t1) has a KEY ( char(8) ) column, with a clustered index. this is not...
1
by: MLH | last post by:
In an Access 97 form, I have a textbox control with the following code that runs AfterUpdate... Option Compare Database Option Explicit Private Sub UNIXdate_AfterUpdate() Me!RealDate =...
1
by: John E. | last post by:
I cannot seem to find the equivilant of assigning a range to an array in c#. In other languages you can do something like: @myArray = ("a" .. "z"); or something to that effect. Thus creating...
85
by: Russ | last post by:
Every Python programmer gets this message occasionally: IndexError: list index out of range The message tells you where the error occurred, but it doesn't tell you what the range and the...
2
by: adamjroth | last post by:
Hello, I'm having trouble with IE's Range/Selection objects: when a user click's anywhere in an element, can I create a range at that point exactly _AND_ get the character offset? The code...
2
by: a1drich | last post by:
smartCryptor.cpp: In function `void Char2Hex(unsigned char, char*)': smartCryptor.cpp:188: warning: comparison is always true due to limited range of data type void Char2Hex(unsigned char...
20
by: Junmin H. | last post by:
Hello, I am trying to print the range of unsigned char and unsigned int. The one for char is working good, gives me a correct output, however the other one for int doesnt, why?? Thanks #include...
9
by: naunetr | last post by:
hi all, i'm reading the "tomsweb" tutorial here http://cprog.tomsweb.net/cintro.html and it says that range of signed char is -127...+127. but this prog prints -128...127. also my textbook says...
5
by: pereges | last post by:
I wrote a small program to check the range for int(signed) and long int(signed) on my machine: #include <stdio.h> #include <limits.h> int main(void) { printf("INT_MIN:%d INT_MAX: %d",...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
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...

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.