Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!news.funet.fi!hydra!cc.helsinki.fi!wirzenius From: wirzenius@cc.helsinki.fi (Lars Wirzenius) Newsgroups: comp.lang.c Subject: Re: 32 bit longs Message-ID: <1991Jan25.002522.4645@cc.helsinki.fi> Date: 25 Jan 91 00:25:22 GMT References: <14824@smoke.brl.mil> <1991Jan22.022206.24691@tkou02.enet.dec.com> Distribution: comp Organization: University of Helsinki Lines: 20 In article <1991Jan22.022206.24691@tkou02.enet.dec.com>, diamond@jit345.swstokyo.dec.com (Norman Diamond) writes: > In article <231@nazgul.UUCP> bright@nazgul.UUCP (Walter Bright) writes: >> >>If you have a need for *exactly* 32 bits, you can do things like: >> if (sizeof(x) == 4) >> /* code here depends on 32 bits in x */ > > On a machine with 36-bit words and C support hacked with 9-bit chars, > this test will give an undesired result. Wouldn't the following work (assuming CHAR_BIT is defined properly), if the aim is to verify that x has a size of 32 bits: if (sizeof(x) * CHAR_BIT == 32) By the way, is there any guarantee that all bits are used to represent a value? That is, does a 16-bit unsiged always have a value range of 0..65535? Lars Wirzenius wirzenius@cc.helsinki.fi