Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Waldby <not@valid.invalid> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Union test for endianess |
| Date | 2011-06-18 02:53 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <ith3vr$90o$1@dont-email.me> (permalink) |
| References | <f19541de-213c-4744-b712-92f20a3ad294@d26g2000prn.googlegroups.com> <itfl14$g6b$1@dont-email.me> <4eb1a4f9-c71d-4c36-a5e6-8e76cfef947b@d1g2000yqm.googlegroups.com> <ln7h8kyqhc.fsf@nuthaus.mib.org> |
On Fri, 17 Jun 2011 16:42:39 -0700, Keith Thompson wrote: > "christian.bau" ... writes: ... >> Is there actually any guarantee in the C Standard that there is such a >> thing as "byte order"? I thought with 32 bit ints stored in 32 bits >> worth of bytes there would be 32! (32 factorial) possible bit orders? > > C99 6.2.6.1 requires a "pure binary notation" for unsigned bit-fields > and objects of type unsigned char, with a footnote: [#40 that defines pure binary] > The words "positional" and "successive" imply to me that only two bit > orders are permitted for unsigned char. (Or perhaps just one; it's not > at all clear that there's even any meaning to the positions of the bits > beyond the values they represent.) > > 6.2.6.2, discussing the representation of unsigned integer types, again > uses the phrase "pure binary notation". > > Each integer type is required to have the same values for its value bits > as the corresponding bits in the corresponding unsigned type. > > Though it's not 100% clear what "successive" means. I supppose it could > just mean traversing the bits in order of the values they represent, > which isn't necessarily the same as either the order of the bits in the > constituent bytes or the physical order (if that's even meaningful). On general purpose computers without special sensors, no portable program can discover the relative spatial positions of electrons that represent data bits, making physical order of bits irrelevant. The logical succession order of bits in unsigned chars as revealed by C's <<, >> shift operators cannot differ from arithmetic order, because C99 6.5.7 specifies <<, >> in terms of multiplication and division by powers of 2. It appears that in the context of C99 C there is only one possible bit succession order within unsigned bit fields and unsigned chars, which is the 1, 2, 4... order referred to in footnote 40. > I think that either it permits 32 factorial bit orders for a 32-bit > integer, or it forbids PDP-11 middle-endian order (and I seriously doubt > that the latter was intended.) Apparently the PDP-11 order is allowed. When CHAR_BIT is 8, a 32-bit integer is composed of 4 bytes. By 6.2.6.1 para. 2, "Except for bit-fields, objects are composed of contiguous sequences of one or more bytes, the number, order, and encoding of which are either explicitly specified or implementation-defined." -- jiw
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Union test for endianess Bhasker Penta <bskdsp@gmail.com> - 2011-06-16 20:16 -0700
Re: Union test for endianess Ian Collins <ian-news@hotmail.com> - 2011-06-17 15:36 +1200
Re: Union test for endianess Willem <willem@toad.stack.nl> - 2011-06-17 14:13 +0000
Re: Union test for endianess Joe Wright <joewwright@comcast.net> - 2011-06-17 14:00 -0400
Re: Union test for endianess Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-19 19:25 +0000
Re: Union test for endianess China Blue Angels <chine.bleu@yahoo.com> - 2011-06-16 20:54 -0700
Re: Union test for endianess Willem <willem@toad.stack.nl> - 2011-06-17 14:14 +0000
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-17 10:28 -0400
Re: Union test for endianess Keith Thompson <kst-u@mib.org> - 2011-06-17 10:54 -0700
Re: Union test for endianess Shao Miller <sha0.miller@gmail.com> - 2011-06-17 10:35 -0500
Re: Union test for endianess "J. J. Farrell" <jjf@bcs.org.uk> - 2011-06-18 01:50 +0100
Re: Union test for endianess China Blue Angels <chine.bleu@yahoo.com> - 2011-06-16 21:00 -0700
Re: Union test for endianess Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-06-17 12:09 +0100
Re: Union test for endianess Shao Miller <sha0.miller@gmail.com> - 2011-06-17 00:50 -0500
Re: Union test for endianess Bhasker Penta <bskdsp@gmail.com> - 2011-06-16 23:17 -0700
Re: Union test for endianess Shao Miller <sha0.miller@gmail.com> - 2011-06-17 03:01 -0500
Re: Union test for endianess Shao Miller <sha0.miller@gmail.com> - 2011-06-17 13:33 -0500
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-18 09:18 -0400
Re: Union test for endianess Shao Miller <sha0.miller@gmail.com> - 2011-06-19 17:22 -0500
Re: Union test for endianess Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-19 16:24 -0700
Re: Union test for endianess Bhasker Penta <bskdsp@gmail.com> - 2011-06-18 01:08 -0700
Re: Union test for endianess Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-19 15:52 -0700
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-17 09:32 -0400
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-17 09:52 -0400
Re: Union test for endianess Bhasker Penta <bskdsp@gmail.com> - 2011-06-17 07:13 -0700
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-17 10:31 -0400
Re: Union test for endianess "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2011-06-17 15:57 -0700
Re: Union test for endianess Keith Thompson <kst-u@mib.org> - 2011-06-17 16:42 -0700
Re: Union test for endianess James Waldby <not@valid.invalid> - 2011-06-18 02:53 +0000
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-17 23:59 -0400
Re: Union test for endianess James Waldby <not@valid.invalid> - 2011-06-18 14:45 +0000
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-18 11:08 -0400
Re: Union test for endianess cri@tiac.net (Richard Harter) - 2011-06-18 19:47 +0000
Re: Union test for endianess James Waldby <not@valid.invalid> - 2011-06-18 23:15 +0000
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-18 22:42 -0400
Re: Union test for endianess Jens <jens.gustedt@gmail.com> - 2011-06-19 07:41 -0700
Re: Union test for endianess Roberto Waltman <usenet@rwaltman.com> - 2011-06-22 11:25 -0400
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-22 11:40 -0400
Re: Union test for endianess James Waldby <not@valid.invalid> - 2011-06-22 21:42 +0000
Re: Union test for endianess James Kuyper <jameskuyper@verizon.net> - 2011-06-17 21:18 -0400
Re: Union test for endianess falk@rahul.net (Edward A. Falk) - 2011-06-17 20:50 +0000
Re: Union test for endianess "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-06-18 10:42 -0400
Re: Union test for endianess Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-06-18 22:55 +0100
Re: Union test for endianess "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-06-19 21:14 -0400
Re: Union test for endianess Jens <jens.gustedt@gmail.com> - 2011-06-19 07:46 -0700
Re: Union test for endianess Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-19 16:14 -0700
Re: Union test for endianess Shao Miller <sha0.miller@gmail.com> - 2011-06-19 20:24 -0500
Re: Union test for endianess Jens <jens.gustedt@gmail.com> - 2011-06-20 00:31 -0700
Re: Union test for endianess Shao Miller <sha0.miller@gmail.com> - 2011-06-20 04:33 -0500
Re: Union test for endianess Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-20 12:22 -0700
csiph-web