🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4426

Re: char

#4426
From: Clive D.W. Feather
Date: Tue, 05 Dec 1995 06:19
30 lines
1623 bytes
In article <49uh73$hqp@gabi.gabi-soft.fr>, J. Kanze <kanze@gabi-soft.fr> wrote:
> Finally.  So I'm not the only one.  Not only do negative codes sound
> odd, they aren't acceptable input for the ctype functions.

The ctype functions are defined in terms of "characters cast to unsigned
char".

>|>  And can these expressions :
>|> (signed char) foo != 0
>|>  and
>|> (unsigned char) foo != 0
>|>  differ in result ?

Yes, they can.

> "When a value with
> integral type is converted to another integral type, if the value can be
> represented by the new type, its value is unchanged."  Implementation
> limits require that 0 be representable in all integral types.

Irrelevant. When a signed char is converted to an unsigned char,
negative values are converted in an implementation-defined manner. It
may well be that there is a negative value which converts to zero.
Provided that this value has the same properties as '\0' as far as the
ctype functions are concerned, this is conforming.

-- 
Clive D.W. Feather                       | If you lie to the compiler,
clive@demon.net        (work, preferred) | it will get its revenge.
clive@stdc.demon.co.uk (home)            |   - Henry Spencer
Technical Details
Message-ID: <DJ3o8r.J94@stdc.demon.co.uk>
Path: arc1-ca.pugleaf.net!stdc.demon.co.uk!clive
References: <49sath$n7k@news.cic.net> <49uh73$hqp@gabi.gabi-soft.fr>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!stdc.demon.co.uk!clive
From: clive@stdc.demon.co.uk (Clive D.W. Feather)
Newsgroups: comp.std.c
Subject: Re: char
Date: Tue, 5 Dec 1995 06:19:38 GMT
Organization: Demon Internet Limited (personal account)
Message-ID: <DJ3o8r.J94@stdc.demon.co.uk>
References: <49sath$n7k@news.cic.net> <49uh73$hqp@gabi.gabi-soft.fr>
Reply-To: clive@demon.net
X-NNTP-Posting-Host: stdc.demon.co.uk