rbj%icst-cmr@smoke.UUCP (04/16/86)
> > Consider the following problem. You have an array of 4 byte > > integers. If you sort the array numerically you get one result. If > > you regard the bytes as characters and sort them lexicographically on > > a little endian machine you get a different result. The reason is that > > the most signifigant byte occupies the eight least signifigant bits. > > Consistency of signifigance requires that the direction of signifigance > > be the same for both bytes and bits. > > If your machine has unsigned characters and two's-complement integers with > the sign bit in the high bit -- e.g. 360/370 -- then neither byte order > will make the two comparisons come out the same. So quite apart from all > the other flaws in this argument, it just doesn't work. > Before you start defending signed characters, remember that they were > another arbitrary invention of the pdp11. And a mistake, too. > -- > Henry Spencer @ U of Toronto Zoology > {allegra,ihnp4,decvax,pyramid}!utzoo!henry Well, the PDP had some trouble cramming all it's instruxions into those sixteen bit words. Left out was byte arithmetic. I think we all agree that both signed and unsigned operations are desirable on all integer sizes. Bytes not only hold chars, but also small integers. If restricted to only one flavor, I would choose signed any day. It it easier on a PDP-11 to mask the high byte if unwanted than to generate it (sign extend) if needed. (Root Boy) Jim Cottrell <rbj@cmr>
dick@tjalk.UUCP (04/18/86)
I just dropped into this, and it may have been said before, but if there is char and unsigned char, I expect the char to be signed. Dick Grune Vrije Universiteit de Boelelaan 1081 1081 HV Amsterdam the Netherlands
henry@utzoo.UUCP (Henry Spencer) (04/22/86)
> If restricted to only one flavor [of bytes], I would choose signed any day. > It it easier on a PDP-11 to mask the high byte if unwanted than to > generate it (sign extend) if needed. But one ends up doing the masking a lot more often. I believe Dennis has said that he now regrets the concession to the hardware of making char signed in the original C implementation. -- Support the International League For The Derision Henry Spencer @ U of Toronto Zoology Of User-Friendliness! {allegra,ihnp4,decvax,pyramid}!utzoo!henry
davidsen@steinmetz.UUCP (Davidsen) (05/06/86)
In article <570@tjalk.UUCP> dick@vu44.UUCP (Dick Grune) writes: >I just dropped into this, and it may have been said before, but if there >is char and unsigned char, I expect the char to be signed. X3J11 (ANSI C committee) added "signed char". If you assume that your char is signed your code is highly non-portable. -- -bill davidsen seismo!rochester!steinmetz!--\ / \ ihnp4! unirot ------------->---> crdos1!davidsen \ / chinet! ---------------------/ (davidsen@ge-crd.ARPA) "Stupidity, like virtue, is its own reward"