Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!ames!uhccux!virtue!comp.vuw.ac.nz!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Determining machine characteristics (was: IsUnsigned() function?) Message-ID: <3473@goanna.cs.rmit.oz.au> Date: 26 Jul 90 01:46:25 GMT References: <1990Jul16.214155.5087@Neon.Stanford.EDU> <2936@mtung.ATT.COM> <17148@haddock.ima.isc.com> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 20 In article <17148@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) provides some nice macros > #define is_twos_complement() ((-2 | -3) == -1) > #define is_ones_complement() ((-1 & -2) == -3) > #define is_sign_magnitude() ((-1 | -2) == -3) and says > I'd also like to be able to do `is_big_endian()' and `is_little_endian()', but > I think these require run-time code. It's clear that an arithmetic expression which appears in _code_ must be evaluated as if evaluated by the target machine, but need arithmetic expressions in #ifs be evaluated the same way? Is it possible for #if is_ones_complement() to succeed and if (is_ones_complement()) to fail? -- Science is all about asking the right questions. | ok@goanna.cs.rmit.oz.au I'm afraid you just asked one of the wrong ones. | (quote from Playfair)