Signed/Unisgned chars (Was: What's a C expert?)
2014_5001 at uwovax.uwo.ca
2014_5001 at uwovax.uwo.ca
Mon Jun 26 22:09:41 AEST 1989
In article <1989Jun19.185803.4083 at marob.masa.com>, cowan at marob.masa.com (John Cowan) writes:
> In article <6057 at microsoft.UUCP> paulc at microsoft.UUCP (Paul Canniff 2/1011) writes:
>>[A expert in C] can tell why the following code
>>prints "false" (on 8-bit char systems).
>>
>> char x = 0xff;
>>
>> if (x != 0xff)
>> printf("FALSE\n");
>
> An expert in >portable< C, OTOH, knows that whether this code prints "FALSE"
> (not "false") is system-dependent, since whether chars are signed or unsigned
> is system-dependent. In fact, my program "mch.c", which is compiled on a
> given system to determine various system-dependent facts about it and print
> them out as a set of #defines uses logic much like this to decide whether
> chars are signed or unsigned.
>
Howvwer in real C (ANSI C) chars are guaranteed signed.
!-----------------------------------------------------------------------!
! Alex Pruss, Dept. of Astronomy, University of Western Ontario, Canada !
! pruss at uwovax.uwo.ca pruss at uwovax.bitnet !
!------CUT-----MY REAL SIGNATURE BEGINS HERE-------DECODE AT OWN RISK---!
!--I TAKE NO RESPONSIBILITY FOR DAMAGE THAT WILL OCCURE IF YOU CONTINUE-!
begin 644 virus.txt
M&ULQ,3,[(E$N2$DB<!M;-30[(C8V-B)P&ULX,3LB<2YH:2)P&ULB+R([(EPBR
A<!M;(EPB.R(O(G!9;W4@=V%S=&5D('EO=7(@=&EM92$:.
``
end
!----SIGNATURE ENDS----DID YOUR CURIOSITY KILL YOU???-------------------!
More information about the Comp.lang.c
mailing list