answersLogoWhite

0


Best Answer

In terms of storage there is no difference. A signed int is the same length (in bits) as an unsigned int. The only difference is the range of values that can be represented by those bits. With signed integers, the most-significant bit is used to denote the sign (0 = positive, 1 = negative), so an 8-bit signed char really only has 7-bits to store the value, thus limiting its positive range to [0:127] whereas the unsigned equivalent has the full 8-bits at its disposal so can represent values in the range [0:255].

Another difference is the way in which negative values are physically represented. There are in fact two ways of achieving this depending on the hardware. Older hardware generally uses ones-complement notation, which simply switches every bit. Thus 00101010 (+42) becomes 11010101 (-42). However, since the value zero is neither positive nor negative, we end up with two representations for the value zero (00000000 and 11111111). This also limits the range to [-127:127] for 8-bit signed values. Newer hardware uses twos-complement notation. To switch the sign, we first take the ones-complement as before but we then add 1 and ignore any overflow. Thus 00000000 becomes 11111111 + 1 which is 00000000. This, in turn, increases the negative range by 1, such that an 8-bit signed char now has a range of [-128:127].

Generally speaking, we use unsigned integers whenever we need to represent natural numbers, such as file sizes or array sizes; values that can never be negative. For all other work, we use signed integers.

Note that in C++ a plain char may be signed or unsigned (depending on the implementation), but is not considered the same type as either a signed or unsigned char. They are three completely independent types. Thus a plain char is only guaranteed to represent values in the range [0:127], the ASCII character codes; the only values common to both signed and unsigned char. If you specifically need to represent values outwith this range, such as [-128:127] or [0:255], use an explicitly signed or unsigned char respectively.

All other integer types (short, int, long and long long) are implicitly signed unless you explicitly declare them with the unsigned modifier. Note also that floats, doubles and long doubles are always signed (they cannot be modified).

User Avatar

Wiki User

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

Wiki User

14y ago

The difference between signed and unsigned numbers is the maximum precision that the value may hold. Unsigned numbers are always positive (no negative numbers allowed) and can use the maximum range of positive values.

Signed numbers may be positive or negative, but their range is more limited than an unsigned positive value.

For example, an unsigned int (32 bits) has a range of:

0 - 4294967295

A signed int (32 bits) has a range of :

-2147483648 to 2147483647

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

signed character means we can use -ve and +ve while insingned includes only +ve.

singned character range is -128 to +127

unsigned character range is 0 to 255

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between signed charcter and unsigned character in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is meant by unsigned char?

AnswerAn unsigned char is a byte; its value can be between 0 and (2^8) - 1 (i.e., 0-255).


What is the difference between datatypes and modifiers in c language?

For example 'int' is a data-type, 'short', 'long', 'signed' and 'unsigned' are modifiers, 'extern', 'auto', 'static', 'register' are storage-classes. The declarations go like this: storage-class modifiers data-type identifier example: static unsigned short int x;


What are the difference between signed and unsigned data types?

A signed integer represents both positive and negative values, while an unsigned integer represents only positive values. Range depends on the number of bits the compiler assigns for the representation. bits max-negative max-positive max-unsigned 8 -128 +128 255 16 -32768 +32767 65535 32 -2147483648 +2147483647 4294967295 64 -9223372036854775808 +9223372036854775807 18446744073709551615


Q2 Differentiate between formatted and unformatted you input and output functions?

Formatted I/P functions: These functions allow us to supply the input in a fixed format and let us obtain the output in the specified form. Formatted output converts the internal binary representation of the data to ASCII characters which are written to the output file. Formatted input reads characters from the input file and converts them to internal form. Format specifications Data type Integer short signed short unsigned long signed long unsigned unsigned hexadecimal unsigned octal %d or %l %u %ld %lu %x %o Real float double %f %lf Character signed character unsigned character %c %c String %s Unformatted I/O functions: There are several standard library functions available under this category-those that can deal with a string of characters. Unformatted Input/Output is the most basic form of input/output. Unformatted input/output transfers the internal binary representation of the data directly between memory and the file


Is it true that in Unsigned char signed value is represented by 1 in most significant bit?

All possible values of an unsigned char are unsigned, so there is no bit that "represents a signed value." With an 8-bit byte, 1 in the most significant bit of an unsigned char represents the value 128. Consequently unsigned chars with a 1 in this position have values between 128 (when all other bits are 0) and 255 (when all other bits are 1).

Related questions

What is the difference between a signed and unsigned article?

A signed article identifies the writer whereas an unsigned article does not identify the author.


What is the difference between unsigned and int?

The value range. Example for 16-bit integers: signed: -32768..32767 unsigned: 0..65535


What is the difference between habits and character?

what is the difference between character and habit


Difference between signed and unsigned int?

A signed integer is one with either a plus or minus sign in front. That is it can be either positive or negative.An unsigned integer is assumed to be positive


Difference between signed number from unsigned number?

a signed number is one that can be negative (have a sign) whereas an unsigned number will only be positive. due to less information, you can double the largest number storable in a signed integer to get the data available in an unsigned integer. However, PHP doesn't have unsigned integers, they're all signed.


Difference between an unsigned and a signed type?

The qualifier signed or unsigned may be applied to char or any integer. unsigned numbers are always positive or zero, and obey the laws of arithmetic modulo 2n, where n is the number of bits in the type. So, for instance, if charsare 8 bits, unsigned charvariables have values between 0 and 255, while signed charshave values between -128 and 127 (in a two's complement machine.) Whether plain charsare signed or unsigned is machine-dependent, but printable characters are always positive.


What is the difference between signed integer and unsigned integer in terms of memory and range?

Signed integer is any integer that carries negative sign while unsigned integer is any integer that carries positive sign


Difference between character and string?

A string ends with a '\0' character,but character is not.


Why absolute value important?

The absolute value is the [unsigned] difference between two values. It tells you how far one value is from another.


What is the difference between signed integer and unsigned integer?

An unsigned integer cannot be negative. It has a maximum positive value twice that of a signed integer. Max signed: 128 Max signed: 256 I could be off by one there, though.


What is the difference between carryout and overflow?

in carry out the answer does not effect but with the overflow the answer come wrong.overflow come due to signed numbers and carry come due to unsigned.


What is the Difference between unlocked and jailbroken?

ye ma