Article View: comp.std.c
Article #6176Re: How to convert a char into an int from 0 through 255?
From: Karl Heuer
Date: Thu, 11 Jan 1990 18:02
Date: Thu, 11 Jan 1990 18:02
13 lines
1206 bytes
1206 bytes
In article <7544@cs.utexas.edu> Dan Bernstein <stealth.acf.nyu.edu!brnstnd@longway.tic.com> writes:
>((int) ch) & 0xff works and answers my original question, but it won't handle
>machines with more than 256 characters. There's no compile-time way to find
>the right bit pattern---UCHAR_MAX + 1 may not be a power of two.
I believe it is required that all of the U{type}_MAX constants are one less
than a power of two.
I used to think that U{type}_MAX+1 == 1 << (sizeof(type)*CHAR_BIT) was
required, but it seems that Cray has good reasons for violating that identity.
I suppose this is another item to send to X3J11 for interpretation.
Karl W. Z. Heuer (karl@haddock.isc.com or ima!haddock!karl), The Walking Lint
Technical Details
Message-ID:
<15617@haddock.ima.isc.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!spdcc!ima!haddock!karlReferences:
<7544@cs.utexas.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.std.c Subject: Re: How to convert a char into an int from 0 through 255? Message-ID: <15617@haddock.ima.isc.com> Date: 11 Jan 90 18:02:02 GMT References: <7544@cs.utexas.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 13