🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9614

Re: Signed char - What Foolishness Is This!

#9614
From: Ken Thompson
Date: Sat, 18 Oct 1986 02:08
30 lines
2170 bytes
In article <8719@duke.duke.UUCP>, jwg@duke.UUCP (Jeffrey William Gillette) writes:
> []
> 1)      Do other C compilers make 'char' a signed quantity by default?

I use a Masscomp system compatible with System V and BSD 4.2 which
has signed characters by default. I find this very annoying when
porting software from machines with the opposite convention but
it causes no problem with code written for this machine.
> 
> 2)      What possible justification is there for this default?  Is not
> 'char' primarily a logical (as opposed to mathematical) quantity?  What
> I mean is, what is the definition of a negative 'a'?  I can understand 
> the desirability of allowing 'signed char' for gonzo programmers who
> won't use 'short', or who want to risk future compatibility of their
> code on the bet that useful characters will always remain 7-bit entities.
> 
I see no justification for signed characters and the concept of a signed
character is somewhat strange. The problem arises because chars used in
an expression in C are automatically converted to type int. Signed
characters come about when the conversion is made from a char which is
an 8 bit quantity to an int which is 16 bits or larger. I do not know
of any C compilers which actually view a char as an 8 bit signed entity.
Instead the char becomes negative to to sign extension during conversion
to int.

-- 
Ken Thompson  Phone : (404) 894-7089
Georgia Tech Research Institute
Georgia Insitute of Technology, Atlanta Georgia, 30332
...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!thomps
Technical Details
Message-ID: <2421@gitpyr.gatech.EDU>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!elbereth!rutgers!husc6!seismo!gatech!gitpyr!thomps
References: <8719@duke.duke.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!elbereth!rutgers!husc6!seismo!gatech!gitpyr!thomps
From: thomps@gitpyr.gatech.EDU (Ken Thompson)
Newsgroups: net.lang.c,net.micro.pc
Subject: Re: Signed char - What Foolishness Is This!
Message-ID: <2421@gitpyr.gatech.EDU>
Date: Fri, 17-Oct-86 22:08:01 EDT
Article-I.D.: gitpyr.2421
Posted: Fri Oct 17 22:08:01 1986
Date-Received: Tue, 21-Oct-86 23:30:37 EDT
References: <8719@duke.duke.UUCP>
Organization: Georgia Institute of Technology
Lines: 30
Summary: signed chars