answersLogoWhite

0


Best Answer

The range of character data types in C++ is the set of characters in the host's character set.

It is inappropriate to consider the numerical range of such things as characters, because that depends on the particular codeset involved, such as ASCII, EBCDIC, UNICODE, KANJI, etc. Doing that leads to non-portable code, and lazy programming practices. Do not write code that depends on the collating sequence of the character set, or the numerical difference between two characters.

Type char can be signed or unsigned, the value range is -128..127 or 0..255 respectively.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

The range of all the built-in data types in C is implementation-defined. Each implementation provides its own version of the standard library header which specifies the range of all the built-in integral types for that particular implementation. The range of all the built-in precision types (float, double and long double) are similarly defined in the header.

Each value is defined as a macro symbol. To ensure portability across all implementations, it is recommended you use these macros at all times.

CHAR_BIT: specifies the number of bits in all 3 of the integral char data types (plain char, signed char and unsigned char). This value is always at least 8. The length of all other data types are expressed in terms of a char (rather than in terms of bits), where sizeof (char) is always 1. Thus to determine the number of bits in a type T, use the expression sizeof (T) * CHAR_BIT.

SCHAR_MIN: defines the lower range of a signed char. If CHAR_BIT is defined as being 8, then SCHAR_MIN is defined as being -127 on a ones-complement implementation and -128 on a twos-complement implementation. The notation itself is system-defined (and thus implementation defined). Twos-complement is the conventional notation in use today.

SCHAR_MAX: defines the upper range of a signed char. If CHAR_BIT is 8, then SCHAR_MAX is defined as being 127.

UCHAR_MAX: defines the upper range of an unsigned char. If CHAR_BIT is 8, then UCHAR_MAX is defined as being 255.

Note: there is no UCHAR_MIN macro because all unsigned integral types have a lower range of 0.

CHAR_MIN: defines the lower range of a plain char. On implementations where a plain char is signed, CHAR_MIN is defined as being the same as SCHAR_MIN, otherwise it is 0.

CHAR_MAX: defines the upper range of a plain char. On implementations where a plain char is signed, CHAR_MAX is defined as being the same as SCHAR_MAX, otherwise it is defined as being the same as UCHAR_MAX.

There are similar macros dealing with the lower and upper ranges of all other built-in integrals, such as ULONG_MAX for the upper range of an unsigned long int.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are range of character data type in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can an integer data type in c plus plus stores character value?

no


What is the domain of the unsigned character data type?

The unsigned character type has a minimum range of 0 to 255 and is therefore the ideal type to represent integers within this range, in addition to representing all character codes within the extended ASCII character set.


What is difference between '1' and 1 as for us a computer is concerned with respect to c plus plus?

When you type '1' in a C++ program, it is considered to be of character data type(char). When you type 1, it is considered to be of integer data type.


What data type is middle initial?

what data type is Middle initial


What is data and define its type?

Data is information. Data type defines the type of data - integer, character etc


What is a character type data?

text


Is character datatype of Excel?

The name used in Excel for that data type is Text, but it is like the character data type in other computer systems.


Character?

A single letter data type


What data types allows unlimited character input?

String data type allows unlimited character intput


Why subrange does not support real data type in pascal?

SubRange data types take a bit of getting used to, although they are simple in principle. With the standard ordinal (integer and character) types you are allowed a finite range of values. For example, for thebyte type, this is 0 to 255. SubRanges allow you to define your own type with a reduced range of values.


What is java string?

array of character data type which is terminated by null character


How could you use the notation sigma in c plus plus?

There is no symbol for sigma in the ASCII character set, so you would have to use Unicode characters instead. 16-bit Unicode requires the wchar_t data type instead of the usual char data type. You must also use the wide-character streams, wcout and wcin to insert and extract wchar_t sequences.