answersLogoWhite

0


Best Answer

Character.MIN_VALUE = '\u0000' = 0

Character.MAX_VALUE = '\uFFFF' = 65535

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the minimum and maximum value that a char type variable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between char and varchar data types?

The CHAR datatype uses a fixed length, where as the VARCHAR datatype can be variable in length up to the maximum value specified for the length. If you insert "Hello" into a CHAR(10) field, the column would actually contain "Hello " with 5 trailing spaces. The same value inserted in a VARCHAR(10) field would contain "Hello". char datatype is fixed length data type and it store maximum 255 characters while varchardatatype store up to 4000 character of variable length datatype


How do you code a character literal?

char c = 'a'; 'a' is a literal character, which assigns the value 0x61 (ASCII code 97 decimal) to the char variable c. The following lines are therefore equivalent: char a = 0x61; char b = 97; char c = 'a';


What is static char in C?

static storage class in C tells that: The variable will have the default value as zero. The variable scope will be the file in which it is defined. RaVi


What are the implications of using signed vs unsigned bytes in a computer system?

In C programming, the signed and unsignedmodifiers only apply to integer data types: char, short int, int, long int and long long int. Using these modifiers affects the range of values that each of these types can physically represent, however those ranges are implementation-defined.Although we typically regard a byte as being 8 bits in length, this is not the case at all. In programming, a byte is simply the smallest unit of addressable storage on the system, but the length of a byte is actually determined by the machine architecture of that system.In C programming, all data types are measured in chars, thus sizeof (char) is always 1 (byte). However, to determine the number of bits per char we need to examine the CHAR_BITS macro defined in . In most cases this macro is defined with a value of 8 (bits), however we can never assume that is always the case; some systems use a 9-bit byte, others use a 16-bit byte. The only thing the standard guarantees is that CHAR_BITS will be no less than 8. Although 7-bit and 6-bit systems do exist, they are non-standard and therefore require non-standard language implementations.Generally, we don't really need to know the bit-length of an individual char, we simply need to know what range of values the integer types can physically represent (with respect to the current implementation). Again, we look to the macros defined in the implementation's header:SCHAR_MIN : Minimum value signed charSCHAR_MAX : Maximum value signed charUCHAR_MAX : Maximum value unsigned charCHAR_MIN : Minimum value charCHAR_MAX : Maximum value charSHRT_MIN : Minimum value short intSHRT_MAX : Maximum value short intUSHRT_MAX : Maximum value unsigned short intINT_MIN : Minimum value intINT_MAX : Maximum value intUINT_MAX : Maximum value unsigned intLONG_MIN : Minimum value long intLONG_MAX : Maximum value long intULONG_MAX : Maximum value unsigned long intLLONG_MIN : Minimum value long long intLLONG_MAX : Maximum value long long intULLONG_MAX : Maximum value unsigned long long intNote that there are no macros defining the minimum value of unsigned data types because the minimum value for any unsigned data type is always 0. Also, a "plain" int is always signed, hence there is no SINT_MIN or SINT_MAX macro.The char, signed char and unsigned char are three distinct types. The standard does not specify whether a "plain" char should be signed or unsigned, but its range must match that of either the signed char or unsigned char data types. To determine whether a plain char is signed or not, we can use the following:bool signed_char = ((int) CHAR_MAX == (int) SCHAR_MAX) ? true : false;If signed_char is true, a char is equivalent to a signed char, otherwise it is equivalent to an unsigned char.Negative integer values are either represented using ones-complement or twos-complement notation. Again, this is implementation-defined although most modern systems use twos-complement. To determine which notation is in use, we simply look to the minimum value of a signed char. Assuming an 8-bit char, a ones-complement system defines SCHAR_MIN as being -127 while a twos-complement system uses -128.In ones-complement notation, to flip the sign we simply invert all the bits, thus 01010101 becomes 10101010 (the ones-complement of 01010101). The high-order bit denotes the sign (0 for positive, 1 for negative). However, this then means that we have two distinct representations for the value zero: 00000000 (+0) and 11111111 (-0) but zero is neither positive nor negative. To eliminate this inconsistency, twos-complement adds one to the ones-complement, thus 11111111 + 1 = 00000000 (the overflowing bit is simply ignored). By eliminating the redundant representation for -0, the negative range of values increases by 1.One of the implications of using signed and unsigned data types is that we must be careful when performing mixed-mode arithmetic as this can result in "narrowing" or loss of information. For instance:void f (signed char s, unsigned char u) {u = (unsigned) s; // ouch!}Here we used an explicit cast, however if s is negative we will lose information because an unsigned type cannot represent a negative value. Conversely, if s is positive, we don't lose information because the upper range of u exceeds that of s. So before converting between signed and unsigned representations, it is worth ensuring the value is within the range of valid values. When converting from unsigned to signed, it's usually a good idea to use a larger signed data type.


How do you verify the range of variable in c?

The range for all the integral types in C are implementation-defined. To ascertain the range for a specific implementation, include the <limits.h> header where the following macros are defined: CHAR_BIT Number of bits in a char object (byte). SCHAR_MIN Minimum value for an object of type signed char. SCHAR_MAX Maximum value for an object of type signed char. UCHAR_MAX Maximum value for an object of type unsigned char. CHAR_MIN Minimum value for an object of type char. CHAR_MAX Maximum value for an object of type char. MB_LEN_MAX Maximum number of bytes in a multibyte character for any locale. SHRT_MIN Minimum value for an object of type short int. SHRT_MAX Maximum value for an object of type short int. USHRT_MAX Maximum value for an object of type unsigned short int. INT_MIN Minimum value for an object of type int. INT_MAX Maximum value for an object of type int. UINT_MAX Maximum value for an object of type unsigned int. LONG_MIN Minimum value for an object of type long int. LONG_MAX Maximum value for an object of type long int. ULONG_MAX Maximum value for an object of type unsigned long int. LLONG_MIN Minimum value for an object of type long long int. LLONG_MAX Maximum value for an object of type long long int. ULLONG_MAX Maximum value for an object of type unsigned long long int. Similarly, include the <float.h> header for the range of all floating-point types. FLT_RADIX Base for all floating-point types (float, double and long double). FLT_MANT_DIG DBL_MANT_DIG LDBL_MANT_DIG Precision of significand, i.e. the number of digits that conform the significand. FLT_DIG DBL_DIG LDBL_DIG Number of decimal digits that can be rounded into a floating-point and back without change in the number of decimal digits. FLT_MIN_EXP DBL_MIN_EXP LDBL_MIN_EXP Minimum negative integer value for the exponent that generates a normalized floating-point number. FLT_MIN_10_EXP DBL_MIN_10_EXP LDBL_MIN_10_EXP Minimum negative integer value for the exponent of a base-10 expression that would generate a normalized floating-point number. FLT_MAX_EXP DBL_MAX_EXP LDBL_MAX_EXP Maximum integer value for the exponent that generates a normalized floating-point number. FLT_MAX_10_EXP DBL_MAX_10_EXP LDBL_MAX_10_EXP Maximum integer value for the exponent of a base-10 expression that would generate a normalized floating-point number. FLT_MAX DBL_MAX LDBL_MAX Maximum finite representable floating-point number. FLT_EPSILON DBL_EPSILON LDBL_EPSILON Difference between 1 and the least value greater than 1 that is representable. FLT_MIN DBL_MIN LDBL_MIN Minimum representable floating-point number. FLT_ROUNDS Rounding behavior. Possible values: -1 undetermined 0 toward zero 1 to nearest 2 toward positive infinity 3 toward negative infinity Applies to all floating-point types (float, double and long double). FLT_EVAL_METHOD Properties of the evaluation format. Possible values: -1 undetermined 0 evaluate just to the range and precision of the type 1 evaluate float and double as double, and long double as long double. 2 evaluate all as long double Other negative values indicate an implementation-defined behavior. Applies to all floating-point types (float, double and long double). DECIMAL_DIG Number of decimal digits that can be rounded into a floating-point type and back again to the same decimal digits, without loss in precision.


What is the maximum value you can store in an integer a float and a character variable?

There is no definitive answer as the low-level aspects of storage are implementation-defined. The only guarantee provided by the standard is that a character variable (char) must be at least 8-bits in length, but nothing is said about its sign. As such, the maximum value you can guarantee across all implementations is 127. An integer (int) is guaranteed to be at least as long as a character. However, every implementation provides limits.h which defines the valid range for all integers, including a definition for the number of bits in a char. The valid range of floating point values is provided by float.h.


How do you declare two character variable?

One by one: char x; char y; & both together char x,y;


Difference between char and varchar datatypes?

Char is fixed length, while Varchar is variable length.


In C programming a character variable can at a time store how many characters?

You can store one, however if you make a char array: char[50]; You can make a string out of your array of characters.


How do you convert char array into unsigned char array in c?

You can't convert the data type of any variable.


Can you assign a char value to a variable of datatype of byte in java?

Not without casting. A char is a 16 bit type, whereas a byte is an 8 bit type. Therefore the compiler cannot guarantee that the 16 bit value will fit into the 8 bit value without overflowing. If you attempt to stick a char into a byte, you will get a compiler error. To override this, you can cast the char value to a byte during assignment. However, you might get some unexpected results. A few examples below: char a = 'A'; byte b = a; //compiler error char a = 'A'; byte b = (byte)a; //valid, no error. b=65 char a = 172; byte b = (byte)a; //valid, no error, but b=-84 because of overflow.


Can we perform bitwise circular shift in c?

Yes: unsigned char CircLeft (unsigned char value) { if (value&0x80) return (value<<1) + 1; else return (value<<1); } unsigned char CircRight (unsigned char value) { if (value&0x01) return (value>>1) + 0x80; else return (value>>1); }