Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!snorkelwacker.mit.edu!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Portability vs. Endianness Message-ID: <15521@smoke.brl.mil> Date: 20 Mar 91 21:09:49 GMT References: <1991Mar12.105451.19488@dit.upm.es> <2628@ksr.com> <829@saxony.pa.reuter.COM> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 12 In article <829@saxony.pa.reuter.COM> dgil@pa.reuter.COM (Dave Gillett) writes: >> Bytes[0] = (var >> 24) & 0xFF; >> Bytes[1] = (var >> 16) & 0xFF; >> Bytes[2] = (var >> 8) & 0xFF; >> Bytes[3] = var & 0xFF; > I don't think that the standard guarantees that chars are eight bits. It does guarantee that they can hold AT LEAST 8 bits. Assuming sufficient care is taken with use of unsigned types, etc., that is not a problem. However, as mentioned before, the failure to consider representation issues for negative values can be a problem, depending on the implementation.