Path: 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 In article <7544@cs.utexas.edu> Dan Bernstein 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