By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,949 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,949 IT Pros & Developers. It's quick & easy.

Meaning of unsigned char

P: n/a
Hi,
I need clarification regarding signed characters in the C
language.

In C, char is 1 byte. So

1. Unsigned char

[0 to 127] - ASCII CHARACTER SET
[128 to 255] - EXTENDED CHARACTER SET

2. Signed char
[-128 to 0] - ?????
[0 to 127] - ASCII CHARACTER SET

What does it mean for a character to be signed ? Is there any
difference between signed and unsigned char ? If Yes, how do they
differ. If No, then why didnt the C standard restrict the char data
type to unsigned alone.

I have been referring to various articles, but in vain. Any help would
be greatly appreciated.

Regards,
Sarathy

Aug 14 '06 #1
Share this Question
Share on Google+
42 Replies


P: n/a
sarathy wrote:
Hi,
I need clarification regarding signed characters in the C
language.

In C, char is 1 byte. So
In C, characters and bytes are /the same thing/, and need not by only
8 bits wide.
1. Unsigned char

[0 to 127] - ASCII CHARACTER SET
C doesn't require ASCII.
[128 to 255] - EXTENDED CHARACTER SET
C doesn't know anything about "the extended character set".
(Not in the C locale, anyway.)
2. Signed char
[-128 to 0] - ?????
[0 to 127] - ASCII CHARACTER SET
Mostly dittos.

What C /does/ say is that the C-defined characters are positive,
if I recall correctly.
What does it mean for a character to be signed ?
A value of type `signed char` may be negative. A value of type
`unsigned char` cannot be negative. The type `char` is equivalent
to one of them (but is not the /same type/).
Is there any difference between signed and unsigned char ?
Yes, as above.
If Yes, how do they differ.
If No, then why didnt the C standard restrict the char data
type to unsigned alone.
Because when C was standardised, some implementations had
char being signed, and some had char being unsigned. So
char was left ambiguous and the two other flavours were
introduced to allow the programmer to be explicit.

--
Chris "seeker" Dollin
"No-one here is exactly what he appears." G'kar, /Babylon 5/

Aug 14 '06 #2

P: n/a
sarathy posted:
Hi,
I need clarification regarding signed characters in the C
language.

In C, char is 1 byte.

Yes it is. The amount of bits in a byte can be determined from the CHAR_BIT
macro.

So

1. Unsigned char

[0 to 127] - ASCII CHARACTER SET
[128 to 255] - EXTENDED CHARACTER SET

All C cares about is this:

(1) sizeof(char unsigned) == 1

(2) Minimum range: 0 through 255

2. Signed char
[-128 to 0] - ?????
[0 to 127] - ASCII CHARACTER SET

All C cares about is this:

(1) sizeof(char signed) == 1

(2) Minimum range: -127 through 127

What does it mean for a character to be signed?

It can store a negative value.

Is there any difference between signed and unsigned char ?

They're both integer types, just like "int", "short" and "long". See their
minimum range above.

If Yes, how do they differ.

They differ in their signedness, (and consequently, their range).

If No, then why didnt the C standard restrict the char data
type to unsigned alone.

The type used for storing characters is "char". It is implementation
defined as to whether a plain char is signed or unsigned. There's no good
reason to use a plain char for arithmetic or storing numbers.

"unsigned char" is an unsigned integer type.

"signed char" is a signed integer type.

It seems to me that you're confused by its name. Yes, the fact that it's
called "char" suggests that it might not just be a simple integer type, but
it is.

--

Frederick Gotham
Aug 14 '06 #3

P: n/a
"sarathy" <sp*********@gmail.comwrites:
I need clarification regarding signed characters in the C
language.

In C, char is 1 byte. So

1. Unsigned char

[0 to 127] - ASCII CHARACTER SET
[128 to 255] - EXTENDED CHARACTER SET

2. Signed char
[-128 to 0] - ?????
[0 to 127] - ASCII CHARACTER SET

What does it mean for a character to be signed ? Is there any
difference between signed and unsigned char ? If Yes, how do they
differ. If No, then why didnt the C standard restrict the char data
type to unsigned alone.
A char is one byte by definition, specifically, by the C standard's
definition of the word "byte". This doesn't necessarily match the way
the word "byte" is used in other contexts.

The number of bits in a byte is specified by the constant CHAR_BIT in
<limits.h>. It must be at least 8, but it can be larger. (You're not
likely to run into systems with CHAR_BIT 8, unless you work with
embedded systems, particularly DSPs, but you still shouldn't assume
that CHAR_BIT==8.)

char, signed char, and unsigned char are all integer types, capable of
representing integer values within certain ranges. For signed char,
the range is at least -127 to +127. For unsigned char, it's at least
0 to 255. The range of char matches one of those ranges.

These numeric types can (and very often are) used to store character
values, sometimes ASCII, sometimes some other encoding. If the
encoding specifies the meanings of characters 0 to 127, as ASCII does,
then those numeric char values wiill correspond to those characters.
Numeric values outside that range may not have any specified meaning
as characters, but they're still perfectly valid as numeric values.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 14 '06 #4

P: n/a
Frederick Gotham <fg*******@SPAM.comwrites:
[...]
All C cares about is this:

(1) sizeof(char unsigned) == 1

(2) Minimum range: 0 through 255
[...]
All C cares about is this:

(1) sizeof(char signed) == 1

(2) Minimum range: -127 through 127
A note to the original poster: "char unsigned" and "char signed" are
just perverse ways of writing "unsigned char" and "signed char",
respectively. Both forms are allowed by the grammar, but hardly
anyone uses the forms Frederick insists on using. You should
understand what they mean, but don't expect to see them very often.
I strongly recommend not using them in your own code.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 14 '06 #5

P: n/a
Keith Thompson posted:
A note to the original poster: "char unsigned" and "char signed" are
just perverse ways of writing "unsigned char" and "signed char",
respectively.
A note to the original poster: The C language has a less-than-strict syntax
when it comes to word ordering. A lot of the time, the programmer has
choice over what order to put the words in; for instance, all of the
following definitions are equivalent:

const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;

You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier, rather than after, i.e.:

unsigned char

I myself prefer a different form:

char unsigned

The original poster should note that some programmers may deem as
"perverse", styles which are different from their own -- not unlike how a
heterosexual might deem homosexuality to be perverse.

The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.

I suggest to the original poster that he or she write their definitions in
whatever word order they like best.

Both forms are allowed by the grammar, but hardly
anyone uses the forms Frederick insists on using. You should
understand what they mean, but don't expect to see them very often.
I strongly recommend not using them in your own code.

Better yet, I strongly recommend that you realise that word order is at the
programmers discretion in C.

--

Frederick Gotham
Aug 14 '06 #6

P: n/a
Frederick Gotham <fg*******@SPAM.comwrites:
[...]
The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.
Yes, they're equivalent, and yes, any C programmer should know that.
But it's entirely possible that a relatively inexperienced C
programmer might not know that, which is why I chose to explain it to
the OP. Do you have some objection to that?

C also doesn't have any requirements for indentation or brace
placement, but it's very easy to write nearly incomprehensible code by
abusing this flexibility.

"unsigned char" the form conventional is, and no good reason is there
not to it use.
I suggest to the original poster that he or she write their definitions in
whatever word order they like best.
I suggest ignoring anyone who claims that legibility isn't important.
I also suggest ignoring anyone who drags insulting phrases like
"severe mental retardation" into a technical discussion.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 14 '06 #7

P: n/a
Frederick Gotham wrote:
Keith Thompson posted:

>>A note to the original poster: "char unsigned" and "char signed" are
just perverse ways of writing "unsigned char" and "signed char",
respectively.


A note to the original poster: The C language has a less-than-strict syntax
when it comes to word ordering. A lot of the time, the programmer has
choice over what order to put the words in; for instance, all of the
following definitions are equivalent:

const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;

You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier,
Make that most.

--
Ian Collins.
Aug 14 '06 #8

P: n/a
Keith Thompson posted:
Yes, they're equivalent, and yes, any C programmer should know that.
But it's entirely possible that a relatively inexperienced C
programmer might not know that, which is why I chose to explain it to
the OP. Do you have some objection to that?

No. I would point out though that your use of "perverse" was unsuitable.

"unsigned char" the form conventional is, and no good reason is there
not to it use.

We'll just have to agree to disagree on this one, Keith, because I don't
think it makes a hell of a lot of difference either way whether one writes
"char unsigned" or "unsigned char". I just find the former to be more
intuitive.

--

Frederick Gotham
Aug 15 '06 #9

P: n/a
Frederick Gotham wrote:
Keith Thompson posted:
A note to the original poster: "char unsigned" and "char signed" are
just perverse ways of writing "unsigned char" and "signed char",
respectively.

A note to the original poster: The C language has a less-than-strict syntax
when it comes to word ordering. A lot of the time, the programmer has
choice over what order to put the words in; for instance, all of the
following definitions are equivalent:

const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;
No actually, the second one is a syntax error.
You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier, rather than after, i.e.:

unsigned char

I myself prefer a different form:

char unsigned
The vast majority of programmers prefer the first form and with good
reason, when you start mixing things up in unusual and unintuitive ways
it makes it difficult to read and more likely that someone will make a
mistake while doing so (such as the one you made above). Additionally,
the placement of qualifiers in more complicated declarations (such as
pointer variables) often *is* significant and someone who just sprinkes
them around willy-nilly without knowing any better is likely to suffer
the unintended consequences of doing so.
The original poster should note that some programmers may deem as
"perverse", styles which are different from their own -- not unlike how a
heterosexual might deem homosexuality to be perverse.
That's not even worth a response.
The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.
You don't take criticism very well do you? It is a shame that someone
who was starting to build up a good amount of respect for themselves in
this group would be willing to so quickly throw it away by resorting to
imature, child-like, personal attacks on well-respected regulars for no
good reason. You have been here long enough to know that such a
response wouldn't garner you any support or sympathy. Hopefully this
can be chalked up to you having a bad day but I hope you realize that
your response was asinine and uncalled for. I suggest you think twice
about posting such nonsense here again if you want to continue being
taken seriously.

Robert Gamble

Aug 15 '06 #10

P: n/a
Robert Gamble wrote:
Frederick Gotham wrote:
>Keith Thompson posted:
>>A note to the original poster: "char unsigned" and "char signed" are
just perverse ways of writing "unsigned char" and "signed char",
respectively.
A note to the original poster: The C language has a less-than-strict syntax
when it comes to word ordering. A lot of the time, the programmer has
choice over what order to put the words in; for instance, all of the
following definitions are equivalent:

const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;

No actually, the second one is a syntax error.
And so is the third -- due to the typo 'cont'. Gee, 50% right, he barely
passed!

--
Simon.
Aug 15 '06 #11

P: n/a
Robert Gamble posted:
> unsigned char

I myself prefer a different form:

char unsigned

The vast majority of programmers prefer the first form and with good
reason, when you start mixing things up in unusual and unintuitive ways
it makes it difficult to read and more likely that someone will make a
mistake while doing so (such as the one you made above).

The mistake I made was a result of writing quickly and sloppily.

Similarly, from time to time, you'll see me write "their" instead of
"they're", or "its" instead of "it's", or "mens" instead of "men's", even
though I know full well how they should be used.

Additionally, the placement of qualifiers in more complicated
declarations (such as pointer variables) often *is* significant and
someone who just sprinkes them around willy-nilly without knowing any
better is likely to suffer the unintended consequences of doing so.

I have discussed this elsethread. I put them in a particular order. I like
to place emphasis on the type by putting it at the start of a line,
perhaps:

static inline
int const
(*const *Func(void))[12]
{

}

Or, on one line:

int const static inline (*const *Func(void))[12] { }

Some people complain that this mixes the return type with keywords such as
"static" and "inline", but I consider the asterisk to be part of the name
of the function. This is reflected by:

int *p1, *p2;

Recently, I've taken a preference to the multi-line form which I show above
(which places the "static" and "inline" on the preceeding line).

>The original poster should note that some programmers may deem as
"perverse", styles which are different from their own -- not unlike how
a heterosexual might deem homosexuality to be perverse.

That's not even worth a response.

Labeling it as "perverse" because it clashes with other people's styles
borders on fascist ideals not unlike one expressing and asserting one's
homphobia.

Kieth Thompson likes to write "unsigned char"... great! Would you not
consider it fascist that he labels any other perfectly conforming way of
doing it as "perverse"?

>The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.

You don't take criticism very well do you?

Not when people are trying to persuade me that there's an inherent flaw in
writing "char unsigned". Both from reading the Standard, and from my own
programming experience, I have not been convinced that "char unsigned" is
bad style.

It is a shame that someone who was starting to build up a good amount of
respect for themselves in this group would be willing to so quickly
throw it away by resorting to imature, child-like, personal attacks on
well-respected regulars for no good reason.

Firstly, I made no personal attack.

Secondly, respect is fleeting on Usenet. I'm usually accepted quite
graciously at the beginning on newsgroups such as this one, but then when I
don't immediately submit to fascism such as "Don't write it that way, it
confuses us", or "Use signed integer types, not unsigned", the transparency
of any perceived respect becomes apparent.

Two points to make:

(1) I like to write "char unsigned".
(2) I prefer to use unsigned integer types where possible.

I am respected until I choose to defend my way of doing things, and then
blatantly disrespected when I don't immediately succumb to the pressure. It
doesn't take much thought to realise that the concept of respect is a bit
wish-washy here.

I don't seek respect from this group. I seek interesting discussion. I seek
to further my own skill in C. It seems that usage of "char unsigned" breeds
contempt around here. That's unfortunate. Perhaps if I write it enough,
people will see that, as far as the International Standard is concerned,
it's a perfectly conforming, variant word ordering of "unsigned char".

You have been here long enough to know that such a response wouldn't
garner you any support or sympathy.

It seems to be the only way to get through to some people. Without going
off-topic, I'll give a quick summary of a little discussion which took
place over on comp.lang.c++: A person posted seeking advice on using
arrays. I cordially posted advice on using arrays. Regulars were quick to
reply that "arrays are dangerous", and that the original poster should use
the Standard Library's "vector" facility. I responded that arrays are not
dangerous, unless they're used by not-so-apt programmers. Sometimes I have
to use less-euphemistic terms to get the point across.

As an aside, I wasn't aware that my use of "retardation" would cause such a
flurry. If the group would rather that I not use it in such a context, I'll
gladly oblige.

Hopefully this can be chalked up to you having a bad day but I hope you
realize that your response was asinine and uncalled for.

I don't believe so. Perhaps I should start a new thread expressing my point
of view.

I suggest you think twice about posting such nonsense here again if you
want to continue being taken seriously.

It appears I have lost that priviledge since I failed to succumb to the
group's pressure to write "unsigned char". Who would have thought that such
a simple thing would devalue my worth as a human being?

--

Frederick Gotham
Aug 15 '06 #12

P: n/a
Frederick Gotham <fg*******@SPAM.comwrites:
[...]
Labeling it as "perverse" because it clashes with other people's styles
borders on fascist ideals not unlike one expressing and asserting one's
homphobia.

Kieth Thompson likes to write "unsigned char"... great! Would you not
consider it fascist that he labels any other perfectly conforming way of
doing it as "perverse"?
Fascist? Sheesh, get a grip! (And my name is Keith, not Kieth.)

It's possible that you've confused the word "perverse" with
"perverted". If so, your gross overreaction is almost understandable.

Here's the definition of "perverse" from the Merriam Webster Dictionary:

1 a : turned away from what is right or good : corrupt b :
improper, incorrect c : contrary to the evidence or the direction
of the judge on a point of law <perverse verdict>
2 a : obstinate in opposing what is right, reasonable, or accepted
: wrongheaded b : arising from or indicative of stubbornness or
obstinacy
3 : marked by peevishness or petulance : cranky
synonyms: see contrary

Not all of these apply, but in my opinion several of them do. Writing
"char unsigned" is not incorrect; it is merely perverse.

And here's the definition of "fascism" from the same dictionary:

1 often capitalized : a political philosophy, movement, or regime
(as that of the Fascisti) that exalts nation and often race above
the individual and that stands for a centralized autocratic
government headed by a dictatorial leader, severe economic and
social regimentation, and forcible suppression of opposition
2 : a tendency toward or actual exercise of strong autocratic or
dictatorial control <early instances of army fascism and brutality
J. W. Aldridge>

How this applies to what I did (expressing my opinion in a public
forum) I can't imagine. (In case you were wondering, freedom of
expression does not include the right not to be disagreed with.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 15 '06 #13

P: n/a
On Tue, 15 Aug 2006 11:16:14 +1200, Ian Collins <ia******@hotmail.com>
wrote in comp.lang.c:
Frederick Gotham wrote:
Keith Thompson posted:

>A note to the original poster: "char unsigned" and "char signed" are
just perverse ways of writing "unsigned char" and "signed char",
respectively.

A note to the original poster: The C language has a less-than-strict syntax
when it comes to word ordering. A lot of the time, the programmer has
choice over what order to put the words in; for instance, all of the
following definitions are equivalent:

const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;

You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier,
Make that most.
....actually, make that all but the pompous asses.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Aug 15 '06 #14

P: n/a
Frederick Gotham wrote:
Robert Gamble posted:
unsigned char

I myself prefer a different form:

char unsigned
The vast majority of programmers prefer the first form and with good
reason, when you start mixing things up in unusual and unintuitive ways
it makes it difficult to read and more likely that someone will make a
mistake while doing so (such as the one you made above).
The original poster should note that some programmers may deem as
"perverse", styles which are different from their own -- not unlike how
a heterosexual might deem homosexuality to be perverse.
That's not even worth a response.


Labeling it as "perverse" because it clashes with other people's styles
borders on fascist ideals not unlike one expressing and asserting one's
homphobia.
Google (via Princeton) defines perverse as "marked by a disposition to
oppose and contradict" and "contrary", "obstinate", "wayward". So
Keith has a strong opinion of your style as I suspect most programmers
would as well but, unlike yourself, he provided sound rationale for his
opinion and didn't attack you for disagreeing with him like you did.
It should also be noted that others have objected to your "style" in
the past so it can't come as a surprise to you that your insistence on
using it here would evoke a response, especially given the value of
clear and concise code in this group.
Kieth Thompson likes to write "unsigned char"... great! Would you not
consider it fascist that he labels any other perfectly conforming way of
doing it as "perverse"?
No, I can't begin to imagine how you could justify calling that fascist
but please don't feel it neccessary to try to explain it to me.
The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.
You don't take criticism very well do you?

Not when people are trying to persuade me that there's an inherent flaw in
writing "char unsigned". Both from reading the Standard, and from my own
programming experience, I have not been convinced that "char unsigned" is
bad style.

It is a shame that someone who was starting to build up a good amount of
respect for themselves in this group would be willing to so quickly
throw it away by resorting to imature, child-like, personal attacks on
well-respected regulars for no good reason.

Firstly, I made no personal attack.

Secondly, respect is fleeting on Usenet. I'm usually accepted quite
graciously at the beginning on newsgroups such as this one, but then when I
don't immediately submit to fascism such as "Don't write it that way, it
confuses us", or "Use signed integer types, not unsigned", the transparency
of any perceived respect becomes apparent.

Two points to make:

(1) I like to write "char unsigned".
(2) I prefer to use unsigned integer types where possible.

I am respected until I choose to defend my way of doing things, and then
blatantly disrespected when I don't immediately succumb to the pressure. It
doesn't take much thought to realise that the concept of respect is a bit
wish-washy here.
But you didn't defend your way of doing things, you attacked Keith for
presenting a valid criticism (for which he provided sound reasoning),
lost your cool, and compared opinionated coding style differences to
homophobia. I personally don't share your preference and I don't think
you should expect to get very far convincing others to accept it when
you haven't even been able to defend it but that's not what I objected
to. I think that you greatly over-reacted to legitimate criticism.
I don't seek respect from this group. I seek interesting discussion. I seek
to further my own skill in C. It seems that usage of "char unsigned" breeds
contempt around here. That's unfortunate.
The fact that you continue to use a style that you know many people
find unclear when you haven't been able to successfully defend your way
is annoying. What breeds contempt is you using terms like "severe
mental retardation", and calling people fascists for criticizing you
instead of trying to defend your style on its merits.
Perhaps if I write it enough,
people will see that, as far as the International Standard is concerned,
it's a perfectly conforming, variant word ordering of "unsigned char".
Nobody is arguing that it isn't perfectly acceptable from a Standard
perspective but there are plenty of legal constructions that many
people would find repugnant.
>
You have been here long enough to know that such a response wouldn't
garner you any support or sympathy.


It seems to be the only way to get through to some people. Without going
off-topic, I'll give a quick summary of a little discussion which took
place over on comp.lang.c++: A person posted seeking advice on using
arrays. I cordially posted advice on using arrays. Regulars were quick to
reply that "arrays are dangerous", and that the original poster should use
the Standard Library's "vector" facility. I responded that arrays are not
dangerous, unless they're used by not-so-apt programmers. Sometimes I have
to use less-euphemistic terms to get the point across.

As an aside, I wasn't aware that my use of "retardation" would cause such a
flurry. If the group would rather that I not use it in such a context, I'll
gladly oblige.
Most people don't take kindly to being referred to as having "severe
mental retardation", go figure.
>
Hopefully this can be chalked up to you having a bad day but I hope you
realize that your response was asinine and uncalled for.


I don't believe so. Perhaps I should start a new thread expressing my point
of view.
No, please don't.
I suggest you think twice about posting such nonsense here again if you
want to continue being taken seriously.


It appears I have lost that priviledge since I failed to succumb to the
group's pressure to write "unsigned char". Who would have thought that such
a simple thing would devalue my worth as a human being?
Oh come now, don't be so dramatic. Nobody is devalueing (devaluing?
how the heck to you spell that?) your worth as a human being and I
don't think that even your insistence to use "char unsigned" over
"unsigned char" is going to cause more than minor irritation. It was
the way you responded to valid criticism that was objectionable. I was
taken aback by your response, it is unlike you from what I have seen so
far (which has been quite positive overall), which is why I responded
the way I did.

Robert Gamble

Aug 15 '06 #15

P: n/a

Jack Klein wrote:
On Tue, 15 Aug 2006 11:16:14 +1200, Ian Collins <ia******@hotmail.com>
wrote in comp.lang.c:
Frederick Gotham wrote:
Keith Thompson posted:
>
>
>>A note to the original poster: "char unsigned" and "char signed" are
>>just perverse ways of writing "unsigned char" and "signed char",
>>respectively.
>
>
A note to the original poster: The C language has a less-than-strict syntax
when it comes to word ordering. A lot of the time, the programmer has
choice over what order to put the words in; for instance, all of the
following definitions are equivalent:
>
const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;
>
You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier,
>
Make that most.

...actually, make that all but the pompous asses.
Hey wait! Are you saying that because I write
unsigned char and not char unsigned that I'm
not a pompous ass? I resemble that remark!

Aug 15 '06 #16

P: n/a
Frederick Gotham schrieb:
Keith Thompson posted:
>"unsigned char" the form conventional is, and no good reason is there
not to it use.


We'll just have to agree to disagree on this one, Keith, because I don't
think it makes a hell of a lot of difference either way whether one writes
"char unsigned" or "unsigned char". I just find the former to be more
intuitive.
"unsigned char" totally match the English grammar. I wonder what you find
more intuitive about "char unsigned".

Reading this thread, the term "enfant terrible" comes to mind. In French,
the word order is this way.

--
Thomas
Aug 15 '06 #17

P: n/a
On Mon, 14 Aug 2006 22:47:51 GMT, Keith Thompson <ks***@mib.org>
wrote:
>Frederick Gotham <fg*******@SPAM.comwrites:
[...]
>The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.

Yes, they're equivalent, and yes, any C programmer should know that.
But it's entirely possible that a relatively inexperienced C
programmer might not know that, which is why I chose to explain it to
the OP. Do you have some objection to that?

C also doesn't have any requirements for indentation or brace
placement, but it's very easy to write nearly incomprehensible code by
abusing this flexibility.

"unsigned char" the form conventional is, and no good reason is there
not to it use.
One reason to follow this convention is that that's what the C
Standard uses. The latest Standard--C99--has 33 matches for "unsigned
char" and 0 matches for "char unsigned". The C89 Standard is similar
in that respect.

Another reason to follow this convention is that that's what
implementors--most likely heavily influenced by the C Standard--use.

Another reason to follow this convention is that, one would hope,
that's what those who write code that conforms to the C Standard use.

--
jay
Aug 15 '06 #18

P: n/a
Ian Collins wrote:
Frederick Gotham wrote:
Keith Thompson posted:
<snip>
You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier,
Make that most.
all except one?

--
Nick Keighley

Aug 15 '06 #19

P: n/a
Nick Keighley wrote:
Ian Collins wrote:
>>Frederick Gotham wrote:
>>>Keith Thompson posted:


<snip>
>>>You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier,

Make that most.


all except one?
I was deliberately not denying the possibility (however remote) that
there might be another.

--
Ian Collins.
Aug 15 '06 #20

P: n/a
Keith Thompson posted:
Fascist? Sheesh, get a grip! (And my name is Keith, not Kieth.)

It's possible that you've confused the word "perverse" with
"perverted". If so, your gross overreaction is almost understandable.

No confusion.

Here's the definition of "perverse" from the Merriam Webster Dictionary:

1 a : turned away from what is right or good : corrupt b :
improper, incorrect c : contrary to the evidence or the direction
of the judge on a point of law <perverse verdict>
2 a : obstinate in opposing what is right, reasonable, or accepted
: wrongheaded b : arising from or indicative of stubbornness or
obstinacy
3 : marked by peevishness or petulance : cranky
synonyms: see contrary

Not all of these apply, but in my opinion several of them do. Writing
"char unsigned" is not incorrect; it is merely perverse.

This is exactly what I'm talking about -- you label my way of doing things
as "perverse", even though it is perfectly OK. The word "perverse" has
negative connotations. If you're looking for a more neutral word along the
same lines, then perhaps try "uncommon".

Furthermore, you conciously introduced me to a newbie in a disrespectful
way -- stating that my methods are "perverse".

And here's the definition of "fascism" from the same dictionary:

1 often capitalized : a political philosophy, movement, or regime
(as that of the Fascisti) that exalts nation and often race above
the individual and that stands for a centralized autocratic
government headed by a dictatorial leader, severe economic and
social regimentation, and forcible suppression of opposition
2 : a tendency toward or actual exercise of strong autocratic or
dictatorial control <early instances of army fascism and brutality
J. W. Aldridge>

How this applies to what I did (expressing my opinion in a public
forum) I can't imagine.

You are forcing you're way of doing things down other people's throats, and
labelling any other way of doing things as "perverse". That's what I see as
fascist.

--

Frederick Gotham
Aug 15 '06 #21

P: n/a
In article <b8*******************@news.indigo.ie>, Frederick Gotham
<fg*******@SPAM.comwrites
>Keith Thompson posted:
>A note to the original poster: "char unsigned" and "char signed" are
just perverse ways of writing "unsigned char" and "signed char",
respectively.

A note to the original poster: The C language has a less-than-strict syntax
when it comes to word ordering. A lot of the time, the programmer has
choice over what order to put the words in; for instance, all of the
following definitions are equivalent:

const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;

You will find that many C programmers (Keith Thompson included)
I would say virtually "ALL" programmers would agree with Keith... Even
me! (Sorry Keith :-)
>I suggest to the original poster that he or she write their definitions in
whatever word order they like best.

I would not. I would suggest you stick to [un]signed char. Doing it the
other way round will not help you in any way but will confuse many.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Aug 15 '06 #22

P: n/a

The real reason there's even a distinction is based on the original
hardware that C was designed to run on. That was the PDP-11 CPU. The
'11 had very many superb features in its instruction set, but a few
quirks also. IIRC the byte comparison instruction did only a signed
compare, and using a byte register as an index would do a signed
address calculation. Also using a byte register in a word context
would sign extend the byte to 16 bits. Not to mention pointers and
registers were 16-bits wide only, so it was CRITICAL to do unsigned
arithmetic with pointers.

So the C designers were very much aware of the differences between
signed byte (-128 to 127) arithmetic versus unsigned byte (0 to 255)
arithmetic versus signed and unsigned 16-bit arithmetic.

You'll see vestiges of this on other architectures that have signed
bytes, like the POWER PC. A common error is using a "char" to get the
result of getopt(), which results in an infinite loop when getopt tries
to return the end of options code.

Aug 15 '06 #23

P: n/a

sarathy wrote:
Hi,
I need clarification regarding signed characters in the C
language.

In C, char is 1 byte. So

1. Unsigned char

[0 to 127] - ASCII CHARACTER SET
[128 to 255] - EXTENDED CHARACTER SET

2. Signed char
[-128 to 0] - ?????
[0 to 127] - ASCII CHARACTER SET

What does it mean for a character to be signed ? Is there any
difference between signed and unsigned char ? If Yes, how do they
For a signed char the most significant bit is treated as a SIGN
bit(positive or negative) and the remainder is the magnitude ~ (2^7).
For an unsigned char there is no sign bit, and the magnitude is (2^8)
-1.

The same can be applied to the other data types, with appropriate
magnitudes.
differ. If No, then why didnt the C standard restrict the char data
type to unsigned alone.

I have been referring to various articles, but in vain. Any help would
be greatly appreciated.

Regards,
Sarathy
Aug 15 '06 #24

P: n/a
Ancient_Hacker wrote:
The real reason there's even a distinction is based on the original
hardware that C was designed to run on. That was the PDP-11 CPU. The
'11 had very many superb features in its instruction set, but a few
quirks also. IIRC the byte comparison instruction did only a signed
compare, and using a byte register as an index would do a signed
address calculation. Also using a byte register in a word context
would sign extend the byte to 16 bits.
The PDP-11 didn't have "byte registers".

You may be thinking of the behaviour of the MOVB instruction, which
IIRC did sign-extension when the target was a register.
Not to mention pointers and
registers were 16-bits wide only, so it was CRITICAL to do unsigned
arithmetic with pointers.
Again, IIRC, the PDP-11 didn't have "unsigned arithmetic". It just
had twos-complement arithmetic. The condition codes were set as
a result of the add/subtract instructions and it was up to the
following code as to how it dealt with the V or C bits being set.

Just because some addresses would be negative if you treated them
as numbers doesn't mean you had to so something special, not that
I can see anyway.

--
Chris "seeker" Dollin
"Reaching out for mirrors hidden in the web." - Renaissance, /Running Hard/

Aug 15 '06 #25

P: n/a
On 15 Aug 2006 05:18:12 -0700, "Ancient_Hacker" <gr**@comcast.net>
wrote:
>
The real reason there's even a distinction is based on the original
hardware that C was designed to run on.
Please quote context. This doesn't even have any relation to the
message you're replying to!

--
Al Balmer
Sun City, AZ
Aug 15 '06 #26

P: n/a
On Tue, 15 Aug 2006 00:52:35 GMT, Frederick Gotham
<fg*******@SPAM.comwrote:
>Keith Thompson posted:
>Yes, they're equivalent, and yes, any C programmer should know that.
But it's entirely possible that a relatively inexperienced C
programmer might not know that, which is why I chose to explain it to
the OP. Do you have some objection to that?


No. I would point out though that your use of "perverse" was unsuitable.
Since the subject has been beaten past the point of topicality anyway,
what's your objection to "perverse"? Dictionary.com gives four
meanings:

1. Directed away from what is right or good; perverted.
2. Obstinately persisting in an error or fault; wrongly self-willed
or stubborn.
3.
a. Marked by a disposition to oppose and contradict.
b. Arising from such a disposition.
4. Cranky; peevish.

And it seems to me that all four apply here ;-)
>
>"unsigned char" the form conventional is, and no good reason is there
not to it use.


We'll just have to agree to disagree on this one, Keith, because I don't
think it makes a hell of a lot of difference either way whether one writes
"char unsigned" or "unsigned char". I just find the former to be more
intuitive.
--
Al Balmer
Sun City, AZ
Aug 15 '06 #27

P: n/a
On Tue, 15 Aug 2006 02:35:44 GMT, Frederick Gotham
<fg*******@SPAM.comwrote:
>Secondly, respect is fleeting on Usenet. I'm usually accepted quite
graciously at the beginning on newsgroups such as this one, but then when I
don't immediately submit to fascism such as "Don't write it that way, it
confuses us", or "Use signed integer types, not unsigned", the transparency
of any perceived respect becomes apparent.
Did it ever occur to you that there just might be another reason for
the perceived change in others' respect for you? Think about it. It
might be a clue.

--
Al Balmer
Sun City, AZ
Aug 15 '06 #28

P: n/a
In article <11*********************@p79g2000cwp.googlegroups. com>,
Ivanna Pee <fr***@Infectedmail.comwrote:
>For a signed char the most significant bit is treated as a SIGN
bit(positive or negative) and the remainder is the magnitude ~ (2^7).
For an unsigned char there is no sign bit, and the magnitude is (2^8)
-1.
>The same can be applied to the other data types, with appropriate
magnitudes.
Well, that is one of the possibilities in C, but it is not
very common.

C99 places some representation restrictions that did not explicitly
exist in C89. C99 allows three different representations for
signed integers: two's complement, one's complement, and seperate sign
("signed magnitude").

What you have described is signed magnitude. In what you have
described, binary 11111111 is "sign bit set, magnitude binary 1111111"
which would be -127 (decimal). In the much more common two's complement,
the same bit pattern would represent -1 (decimal).
--
Programming is what happens while you're busy making other plans.
Aug 15 '06 #29

P: n/a
Frederick Gotham wrote:
Labeling it as "perverse" because it clashes with other people's styles
borders on fascist ideals not unlike one expressing and asserting one's
homphobia.
I don't think that it's quite that serious.
Kieth Thompson likes to write "unsigned char"... great! Would you not
consider it fascist that he labels any other perfectly conforming way of
doing it as "perverse"?
C keywords are written in the English language. "unsigned" is an
adjective, while "character" and "integer" (from which "char" and "int"
are derived) are nouns. In English the usual word order requires
adjectives to come before the noun that they modify. To an English
speaker, "char unsigned" makes no sense while "unsigned char" makes much
more sense. A French speaker may feel the opposite is true.
Not when people are trying to persuade me that there's an inherent flaw in
writing "char unsigned". Both from reading the Standard, and from my own
programming experience, I have not been convinced that "char unsigned" is
bad style.
An English speaker generally finds it easier to read code that reads
like English.

If the C keywords had been "with sign" and "without sign" then we would
find it natural to write "char without sign" and not "without sign char".

--
Simon.
Aug 15 '06 #30

P: n/a
On 2006-08-15 03:36:14 -0400, Ian Collins <ia******@hotmail.comsaid:
Nick Keighley wrote:
>Ian Collins wrote:
>>Frederick Gotham wrote:

Keith Thompson posted:


<snip>
>>>You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier,
Make that most.


all except one?
I was deliberately not denying the possibility (however remote) that
there might be another.
While I can't say that I've ever written 'char unsigned' in my C code,
I have written 'char const' in some of my C++ code, as this is the
convention used by the boost libraries when passing pointer <OT>or
reference</OTparameters.

Though, I have never seen a compelling reason as to why one would put
the 'unsigned' after the 'char/short/int/long/long long', it can make
sense to put the 'const' (or 'volatile') after the type that it
modifies, as it normalizes the order somewhat (i.e. const modifies the
thing that immediately precedes it)

For example:

(char const) - a constant char
(char const *) - a pointer to a constant char (i.e. 'const' modifies 'char')
(char * const ) - a constant pointer to a char (i.e. 'const' modifies '*')
(char const * const ) - a constant pointer to a constant char

--
Clark S. Cox, III
cl*******@gmail.com

Aug 15 '06 #31

P: n/a
On 2006-08-14 22:35:44 -0400, Frederick Gotham <fg*******@SPAM.comsaid:
Robert Gamble posted:
>>The original poster should note that some programmers may deem as
"perverse", styles which are different from their own -- not unlike how
a heterosexual might deem homosexuality to be perverse.

That's not even worth a response.


Labeling it as "perverse" because it clashes with other people's styles
borders on fascist ideals not unlike one expressing and asserting one's
homphobia.
Do you even know what the word "perverse" means?

From my dictionary:

perverse |pərˈvərs| |pərˌvərs| |pəˌvəːs|
adjective
(of a person or their actions) showing a deliberate and obstinate
desire to behave in a way that is unreasonable or unacceptable, often
in spite of the consequences : Kate's perverse decision not to
cooperate.

That describes your apparent attitude pretty accurately.
Kieth Thompson likes to write "unsigned char"... great! Would you not
consider it fascist that he labels any other perfectly conforming way
of doing it as "perverse"?

>>The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.

You don't take criticism very well do you?


Not when people are trying to persuade me that there's an inherent flaw
in writing "char unsigned". Both from reading the Standard, and from my
own programming experience, I have not been convinced that "char
unsigned" is bad style.
The inherent flaw is that it's different for no reason other than being
different. If it were different because it was objectively better, then
nobody would have a problem with it.
--
Clark S. Cox, III
cl*******@gmail.com

Aug 15 '06 #32

P: n/a

Chris Dollin wrote:
Ancient_Hacker wrote:
The real reason there's even a distinction is based on the original
hardware that C was designed to run on. That was the PDP-11 CPU. The
'11 had very many superb features in its instruction set, but a few
quirks also. IIRC the byte comparison instruction did only a signed
compare, and using a byte register as an index would do a signed
address calculation. Also using a byte register in a word context
would sign extend the byte to 16 bits.

The PDP-11 didn't have "byte registers".

You may be thinking of the behaviour of the MOVB instruction, which
IIRC did sign-extension when the target was a register.
IIRC ALL the two-operand instructions had a bit that controlled whether
the instruction worked on words or bytes. So you had not only MOVB,
but ADDB, SUBB, XORB, CLRB, BISB, BICB, ROLB, etc.... all of which
operated on bytes, in memory or in the lower byte of a register. I
guess the reason I misspoke about "byte registers" is that the handy
little pocket-guide to PDP-11 instructions has the registers
partitioned in half. And they certainly behave as 8-bit registers if
you set that bit.

You're also correct in that there was no separate "unsigned arithmetic"
mode per se, you just had to interpret the sign and overflow states
differently when using unsigned numbers. This became a really big
deal once folks could afford more than 32K of memory-- I remember a lot
of address comparisons broke once addresses could go "negative".

>
Not to mention pointers and
registers were 16-bits wide only, so it was CRITICAL to do unsigned
arithmetic with pointers.

Again, IIRC, the PDP-11 didn't have "unsigned arithmetic". It just
had twos-complement arithmetic. The condition codes were set as
a result of the add/subtract instructions and it was up to the
following code as to how it dealt with the V or C bits being set.

Just because some addresses would be negative if you treated them
as numbers doesn't mean you had to so something special, not that
I can see anyway.

--
Chris "seeker" Dollin
"Reaching out for mirrors hidden in the web." - Renaissance, /Running Hard/
Aug 15 '06 #33

P: n/a
On 2006-08-15 09:15:24 -0400, "Ivanna Pee" <fr***@Infectedmail.comsaid:
>
sarathy wrote:
>Hi,
I need clarification regarding signed characters in the C
language.

In C, char is 1 byte. So

1. Unsigned char

[0 to 127] - ASCII CHARACTER SET
[128 to 255] - EXTENDED CHARACTER SET

2. Signed char
[-128 to 0] - ?????
[0 to 127] - ASCII CHARACTER SET

What does it mean for a character to be signed ? Is there any
difference between signed and unsigned char ? If Yes, how do they

For a signed char the most significant bit is treated as a SIGN
bit(positive or negative) and the remainder is the magnitude ~ (2^7).
For an unsigned char there is no sign bit, and the magnitude is (2^8)
-1.
Note that the signed types don't necessarily have sign and magnitude
representations (and, on current systems, usually don't). It is far
more common to find two's compliment representations.
--
Clark S. Cox, III
cl*******@gmail.com

Aug 15 '06 #34

P: n/a

Walter Roberson wrote:
In article <11*********************@p79g2000cwp.googlegroups. com>,
Ivanna Pee <fr***@Infectedmail.comwrote:
For a signed char the most significant bit is treated as a SIGN
bit(positive or negative) and the remainder is the magnitude ~ (2^7).
For an unsigned char there is no sign bit, and the magnitude is (2^8)
-1.
The same can be applied to the other data types, with appropriate
magnitudes.

Well, that is one of the possibilities in C, but it is not
very common.

C99 places some representation restrictions that did not explicitly
exist in C89. C99 allows three different representations for
signed integers: two's complement, one's complement, and seperate sign
("signed magnitude").

What you have described is signed magnitude. In what you have
described, binary 11111111 is "sign bit set, magnitude binary 1111111"
which would be -127 (decimal). In the much more common two's complement,
the same bit pattern would represent -1 (decimal).
I concur. I was just surprised that in all the responses noone
mentioned a sign bit to the OP. I didn't want to further confuse the OP
with compliment arithmetic, I simply used the word 'magnitude' without
specifics.
--
Programming is what happens while you're busy making other plans.
Aug 15 '06 #35

P: n/a
In article <11*********************@m73g2000cwd.googlegroups. com>,
Ivanna Pee <fr***@Infectedmail.comwrote:
>
Walter Roberson wrote:
>In article <11*********************@p79g2000cwp.googlegroups. com>,
Ivanna Pee <fr***@Infectedmail.comwrote:
>For a signed char the most significant bit is treated as a SIGN
bit(positive or negative) and the remainder is the magnitude ~ (2^7).
For an unsigned char there is no sign bit, and the magnitude is (2^8)
-1.
>What you have described is signed magnitude.
>I concur. I was just surprised that in all the responses noone
mentioned a sign bit to the OP. I didn't want to further confuse the OP
with compliment arithmetic, I simply used the word 'magnitude' without
specifics.
The problem is that your description is not correct for two's
complement representation, because it implies that there is a sign
bit that does not take part in the value representation. In
two's complement representation, the sign bit does officially take part
in the value representation. For example if signed char happened to
be 8 bits, then in two's complement, 0x80 is not "sign bit set, magnitude
bits all 0" (such as might be used to store negative 0 or negative 1):
it would be either a trap representation or else it would be
(0x80 - 0xFF - 1) (that is, 128 - 255 - 1). In this formulation, the value
of all of the bits take part in the calculation. (Whether they officially
officially all take part in the calculation or not only matters for the
case where what you have called the magnitude bits are all 0.)
--
Programming is what happens while you're busy making other plans.
Aug 15 '06 #36

P: n/a
Frederick Gotham <fg*******@SPAM.comwrites:
Keith Thompson posted:
>Fascist? Sheesh, get a grip! (And my name is Keith, not Kieth.)

It's possible that you've confused the word "perverse" with
"perverted". If so, your gross overreaction is almost understandable.

No confusion.
Ok, so your gross overreaction is not understandable.
>Here's the definition of "perverse" from the Merriam Webster Dictionary:
[snip]
>Not all of these apply, but in my opinion several of them do. Writing
"char unsigned" is not incorrect; it is merely perverse.

This is exactly what I'm talking about -- you label my way of doing things
as "perverse", even though it is perfectly OK. The word "perverse" has
negative connotations. If you're looking for a more neutral word along the
same lines, then perhaps try "uncommon".
Let me be very clear. If I had wanted to use a more neutral word, I
would have used one.
Furthermore, you conciously introduced me to a newbie in a disrespectful
way -- stating that my methods are "perverse".
Yes, I did.
>And here's the definition of "fascism" from the same dictionary:
[snip]
>How this applies to what I did (expressing my opinion in a public
forum) I can't imagine.

You are forcing you're way of doing things down other people's throats, and
labelling any other way of doing things as "perverse". That's what I see as
fascist.
I am not forcing anyone to do anything, nor do I wish to do so. You
might consider finding someone who's actually lived under a fascist
regime, and see how much sympathy you get for the oppression you've
experienced here.

I criticized you. Grow up and deal with it. Or continue making a
fool of yourself. It's entirely up to you and, fascist that I am, I
wouldn't have it any other way.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 15 '06 #37

P: n/a
Frederick Gotham wrote:
Keith Thompson posted:
>Fascist? Sheesh, get a grip! (And my name is Keith, not Kieth.)

It's possible that you've confused the word "perverse" with
"perverted". If so, your gross overreaction is almost
understandable.

No confusion.
>Here's the definition of "perverse" from the Merriam Webster
Dictionary:

1 a : turned away from what is right or good : corrupt b :
improper, incorrect c : contrary to the evidence or the
direction of the judge on a point of law <perverse verdict>
2 a : obstinate in opposing what is right, reasonable, or
accepted : wrongheaded b : arising from or indicative of
stubbornness or obstinacy
3 : marked by peevishness or petulance : cranky
synonyms: see contrary

Not all of these apply, but in my opinion several of them do.
Writing "char unsigned" is not incorrect; it is merely perverse.

This is exactly what I'm talking about -- you label my way of
doing things as "perverse", even though it is perfectly OK. The
word "perverse" has negative connotations. If you're looking for a
more neutral word along the same lines, then perhaps try "uncommon".

Furthermore, you conciously introduced me to a newbie in a
disrespectful way -- stating that my methods are "perverse".
And here's the definition of "fascism" from the same dictionary:

1 often capitalized : a political philosophy, movement, or regime
(as that of the Fascisti) that exalts nation and often race above
the individual and that stands for a centralized autocratic
government headed by a dictatorial leader, severe economic and
social regimentation, and forcible suppression of opposition
2 : a tendency toward or actual exercise of strong autocratic or
dictatorial control <early instances of army fascism and brutality
J. W. Aldridge>

How this applies to what I did (expressing my opinion in a public
forum) I can't imagine.

You are forcing you're way of doing things down other people's
throats, and labelling any other way of doing things as "perverse".
That's what I see as fascist.
This is totally ridiculous. Using an unconventional word order can
only lead to confusion, which by itself is a strong argument for
not so doing. Perverse is a perfectly good word, usable in polite
company and applicable to many things, including men, women, and
children. Dogs, luckily, are not so likely to be perverse.
However the height of perversity is to blow it up to full sized
religious war, rather than leaving it what it is - a style point.

--
Chuck F (cb********@yahoo.com) (cb********@maineline.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.netUSE maineline address!
Aug 16 '06 #38

P: n/a
On Mon, 14 Aug 2006 15:16:18 UTC, "sarathy" <sp*********@gmail.com>
wrote:
Hi,
I need clarification regarding signed characters in the C
language.

In C, char is 1 byte. So

1. Unsigned char

[0 to 127] - ASCII CHARACTER SET
[128 to 255] - EXTENDED CHARACTER SET

2. Signed char
[-128 to 0] - ?????
You means -127. -128 can be possible on 2th complement mashines.
[0 to 127] - ASCII CHARACTER SET

What does it mean for a character to be signed ? Is there any
difference between signed and unsigned char ? If Yes, how do they
differ. If No, then why didnt the C standard restrict the char data
type to unsigned alone.
They differ in the same as int and unsigned int or long and unsigned
long differ. The have a sign bit.

The standard names 3 types of char:
char can be signed or unsigned depending on the
environment
unsigned char 0 - 255 no sign bit
signed char -127 - +127
I have been referring to various articles, but in vain. Any help would
be greatly appreciated.
Often signed char is used as short short int to save mempry space.
Sometimes the same for unsigned.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
Aug 16 '06 #39

P: n/a
On Mon, 14 Aug 2006 21:43:35 UTC, Frederick Gotham
<fg*******@SPAM.comwrote:
>
const unsigned long int i = 5;
int long unsigned i const = 5;
cont int long unsigned i = 5;
int unsigned const long i = 5;
Only 1 of multiple millions programmers use that unconventional
crappyx coding, even as it is legal.
You will find that many C programmers (Keith Thompson included) prefer to
place "unsigned" before the size-specifier, rather than after, i.e.:

unsigned char

I myself prefer a different form:
The only, really only programmer on the whole world I've seen in about
30 years programming in C I've ever seen. You are really perverse as
you are the only one of thousends different sources of thousends
programmers I've sighted yet who is so perserve as you.
char unsigned
The real world uses
unsigned char
instead.
The original poster should note that some programmers may deem as
"perverse", styles which are different from their own -- not unlike how a
heterosexual might deem homosexuality to be perverse.

The original poster should note that any human being who doesn't suffer
from severe mental retardation should be able to understand that "char
unsigned" and "unsigned char" are equivalent.

I suggest to the original poster that he or she write their definitions in
whatever word order they like best.

Both forms are allowed by the grammar, but hardly
anyone uses the forms Frederick insists on using. You should
understand what they mean, but don't expect to see them very often.
I strongly recommend not using them in your own code.


Better yet, I strongly recommend that you realise that word order is at the
programmers discretion in C.
Better you realises thet there is an unwritten agreement between all C
programmers on the world to use the word order as defined in any
source other than from you.

It is time intensive to understund your crappy order. Time is money,
so even as it costs litte time for a line, it costs a significant
amout of time for a significant number of lines. That time is spended
more effective on real problems than to decode your crap. Stop writing
your at friendiest sayd "unconventional" style but use here in the
groups the convention the rest of the whole world is using.

Would you ever ty to drive on the left side of the street on the
continent only because YOU means that is better than driving on the
right site?

The whole community gives a shit of your style. It uses that what it
is trained in since C is spreaded outside the labs of K&R.

You may use your style for yorself, but stop braking out others with
that.

You are of really no help for beginners but you are confusing them.

--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
Aug 16 '06 #40

P: n/a
(Increasingly off-topic, so this is the last post I'll
make in this thread about PDP-11s.)

Ancient_Hacker wrote:
Chris Dollin wrote:
>Ancient_Hacker wrote:
The real reason there's even a distinction is based on the original
hardware that C was designed to run on. That was the PDP-11 CPU. The
'11 had very many superb features in its instruction set, but a few
quirks also. IIRC the byte comparison instruction did only a signed
compare, and using a byte register as an index would do a signed
address calculation. Also using a byte register in a word context
would sign extend the byte to 16 bits.

The PDP-11 didn't have "byte registers".

You may be thinking of the behaviour of the MOVB instruction, which
IIRC did sign-extension when the target was a register.

IIRC ALL the two-operand instructions had a bit that controlled whether
the instruction worked on words or bytes. So you had not only MOVB,
but ADDB, SUBB, XORB, CLRB, BISB, BICB, ROLB, etc.... all of which
operated on bytes, in memory or in the lower byte of a register.
That's not how I remembered it, so I checked, and neither of us is
completely wrong ...

Not /all/ the two-operand instructions had byte forms; in particular,
ADD and SUB and MUL and DIV didn't. (I learned PDP-11 assembler on
a machine with no MUL and DIV, in fact, and no XOR either I think.)

So arithmetic on bytes had to be done by putting them into words
(typically, but I suppose not necessarily, registers - there was of
course the stack to hand), and if you used MOVB, it sign-extended.

Except - INC and DEC had -B forms, so adding/subtracting 1 to a char
variable /could/ be done with INCB and DECB. But if that was part of
a conditional -- eg `if (++byte == 128)` -- then the code would have
to go the long way round anyway.
I
guess the reason I misspoke about "byte registers" is that the handy
little pocket-guide to PDP-11 instructions has the registers
partitioned in half. And they certainly behave as 8-bit registers if
you set that bit.
It's an interesting compromise behaviour, since if you do a (non-MOV)
byte operation on a register with bits set in the top byte it (apparently;
I didn't remember this, but bits of the web apparently do) leaves those
bits alone.
You're also correct in that there was no separate "unsigned arithmetic"
mode per se, you just had to interpret the sign and overflow states
differently when using unsigned numbers. This became a really big
deal once folks could afford more than 32K of memory-- I remember a lot
of address comparisons broke once addresses could go "negative".
Yeah. BHI not BGT, etc ...
>Just because some addresses would be negative if you treated them
as numbers doesn't mean you had to so something special, not that
I can see anyway.
.... which I wasn't thinking of as "something special", but clearly it
is.

So you're "unsigned arithmetic" is my "unsigned comparison", and I
think we can be reconciled.

--
Chris "memory lane" Dollin
"No-one here is exactly what he appears." G'kar, /Babylon 5/

Aug 16 '06 #41

P: n/a

Frederick Gotham wrote:
As an aside, I wasn't aware that my use of "retardation" would cause such a
flurry. If the group would rather that I not use it in such a context, I'll
gladly oblige.
Since you ask, I would rather that you did not use such terms, please.

Paul.

Aug 16 '06 #42

P: n/a
gw****@aol.com writes:
Frederick Gotham wrote:
>As an aside, I wasn't aware that my use of "retardation" would cause such a
flurry. If the group would rather that I not use it in such a context, I'll
gladly oblige.

Since you ask, I would rather that you did not use such terms, please.
As would I.

And if you'd care to apologize to me personally for accusing me of
fascism, that would be a welcome gesture.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 16 '06 #43

This discussion thread is closed

Replies have been disabled for this discussion.