-
Character data type
Hello everyone,
Actually I don't have question, but I get confused with character data type in C language. In one book I read that
Data type range
char -128 to 127
unsigned char 0 to 255
In C char is data type which has ASCII values associated with it and ASCII values are positive. It is true or not. Please help me.
Thank you,
rathorek
-
Yes, ASCII values are always positive ranging from 0 to 255.
You can see the characters associated with them here: http://www.lookuptables.com/
Ascii values are the same as Dec
-
Not quite. First off, char isn't necessarily ASCII. On IBM machines it's EBCDIC and theoretically, it could be any byte-sized encoding.
Secondly, ASCII values can be negative. This happens when you try to queeze 255 ASCII code into a signed char. Why do that? Supporting a multilingual system, say Hebrew and English, requires that some characters be mapped to negative values if char is signed by default. From my own experience, it works pretty well.
Danny Kalev
-
ASCII was 0-127 initially as well, the second "half" was added much later on.
-
ASCII was indeed a 128 sign system originally. However, EBCDIC began as a 225 symbol system so it has always needed at least 8 bits. Histroically, EBCDIC was based on BCDIC which used 6 bits (IIRC) back in the days of mechanical computing machines of the 1920s and 1930s. But the point is: char isn't necessarily 8 bits long, char isn't necessarily an ASCII value, and (extended) ASCII values can be negative.
Danny Kalev
-
Thanks to all for your reply.
rathorek
Similar Threads
-
By DH in forum VB Classic
Replies: 2
Last Post: 08-08-2007, 07:03 AM
-
Replies: 0
Last Post: 10-11-2002, 10:52 AM
-
By Sindhu in forum Database
Replies: 0
Last Post: 12-06-2001, 12:28 PM
-
By Maria in forum VB Classic
Replies: 0
Last Post: 05-01-2001, 06:01 PM
-
By Craig in forum Database
Replies: 1
Last Post: 04-24-2001, 09:38 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|