Article View: comp.sys.powerpc
Article #21Re: 64-bit
From: Lawrence Kirby
Date: Mon, 04 Dec 1995 17:00
Date: Mon, 04 Dec 1995 17:00
53 lines
3051 bytes
3051 bytes
In article <49tu81$jcf@otis.netspace.net.au>
reiter@netspace.net.au "Peter Moulder" writes:
>Lawrence Kirby (fred@genesis.demon.co.uk) wrote:
>
>>These seem rather pointless (other than uint32). sint16 is to all intents and
>>purposes equivalent to short.
>
>I suppose there may (in the future, perhaps) be a compiler on which short is
>more than 16 bits; occasionally you do want something to be exactly n bits.
The point is that you can't guarantee exactly n bits. Fir instance on a 36
bit archetecture with 9 bit chars. Given that sint16 is no better than
short.
>>schar8 can't be anything other than signed char.
>
>A char is guaranteed to be a byte, large enough to hold a character of the
>native character set. A byte is usually [but not always] 8 bits.
It is not so much a guarantee as a definition of terms. A byte in C is that
unit of storage required to hold a char (and from constraints on the values
it can hold must be at least 8 bits wide). It need not be related to
any definition of 'byte' in a system's underlying archetecture.
>I'm sorry I can't find my K&R at the moment, so someone can correct me if
>they like. (It's on about p32 or earlier, I think.)
>
>I confess I've never used a compiler where a short wasn't 16 bits and a
>char 8; however, the standard does at least leave room for the suggested
>types to be useful.
A well written program does not depend on the precise width of a type. It
can of course depend on the minimum width guaranteed by the standard. There
are cases where the width of the data is important (e.g. external data
formats) but there are many pitfalls here other than precise width (e.g.
byte order) which mean that types such as sint16 don't solve the problem.
>>To use the language (or at least the standard library) effectively you
>>ultimately need to know what the underlying type is. fprintf and fscanf
>>conversion specifiers are the most clear example of this.
>
>One solution I've used in the past is to cast to or from a long. There can
>still be problems with this, though.
You still need to know which of long, unsigned long or long double is
the most appropriate type to convert to.
--
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------
Technical Details
Message-ID:
<818096400snz@genesis.demon.co.uk>Path:
arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.ukReferences:
<MEISSNER.95Nov9091407@tiktok.cygnus.com> <47tbel$tta@rs18.hrz.th-darmstadt.de> <483pe6$aft@spool.cs.wisc.edu> <wkdrSOS00YUsM7OxBb@andrew.cmu.edu> <48bjig$rgj@inca01.inca.co.nz> <816741669snz@genesis.demon.co.uk> <49tu81$jcf@otis.netspace.net.au>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!genesis.demon.co.uk From: Lawrence Kirby <fred@genesis.demon.co.uk> Newsgroups: comp.sys.powerpc,comp.lang.c Subject: Re: 64-bit Date: Mon, 04 Dec 95 17:00:00 GMT Organization: none Message-ID: <818096400snz@genesis.demon.co.uk> References: <MEISSNER.95Nov9091407@tiktok.cygnus.com> <47tbel$tta@rs18.hrz.th-darmstadt.de> <483pe6$aft@spool.cs.wisc.edu> <wkdrSOS00YUsM7OxBb@andrew.cmu.edu> <48bjig$rgj@inca01.inca.co.nz> <816741669snz@genesis.demon.co.uk> <49tu81$jcf@otis.netspace.net.au> Reply-To: fred@genesis.demon.co.uk X-NNTP-Posting-Host: genesis.demon.co.uk X-Newsreader: Demon Internet Simple News v1.27