<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Working with Bitfields</title>
	<atom:link href="http://iPhoneDeveloperTips.com/c/working-with-bitfields.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/c/working-with-bitfields.html</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Sun, 05 Sep 2010 15:32:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Anonymous</title>
		<link>http://iPhoneDeveloperTips.com/c/working-with-bitfields.html/comment-page-1#comment-157</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 01 Jan 2009 11:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1373#comment-157</guid>
		<description>But i think it is not guaranteed that the compiler decides to pack them like this he might decide to align every bit to a byte adress for performance reasons.

Old versions of vc6 had to be set to explictly pack it using #pragma pack dont know about gcc though.

I think the most reliable solution is (memory &lt;&lt; bitn) &amp; mask.</description>
		<content:encoded><![CDATA[<p>But i think it is not guaranteed that the compiler decides to pack them like this he might decide to align every bit to a byte adress for performance reasons.</p>
<p>Old versions of vc6 had to be set to explictly pack it using #pragma pack dont know about gcc though.</p>
<p>I think the most reliable solution is (memory &lt;&lt; bitn) &amp; mask.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: uprise78</title>
		<link>http://iPhoneDeveloperTips.com/c/working-with-bitfields.html/comment-page-1#comment-154</link>
		<dc:creator>uprise78</dc:creator>
		<pubDate>Mon, 22 Dec 2008 16:26:13 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1373#comment-154</guid>
		<description>Rodney,  Using C sockets you can actually just do a straight send/receive of the struct.  Pseudo code to follow:

typedef struct
{
  unsigned preLoaded: 1;
  unsigned saveState: 1;
  unsigned saveLoginName: 1;
} statusFlags;

// Setup send socket
send(statusFlags)

// Setup receive socket
int count = receive()
if( count &gt; 0 )
{
     statusFlags flags = ( statusFlags *)buffer;
}</description>
		<content:encoded><![CDATA[<p>Rodney,  Using C sockets you can actually just do a straight send/receive of the struct.  Pseudo code to follow:</p>
<p>typedef struct<br />
{<br />
  unsigned preLoaded: 1;<br />
  unsigned saveState: 1;<br />
  unsigned saveLoginName: 1;<br />
} statusFlags;</p>
<p>// Setup send socket<br />
send(statusFlags)</p>
<p>// Setup receive socket<br />
int count = receive()<br />
if( count &gt; 0 )<br />
{<br />
     statusFlags flags = ( statusFlags *)buffer;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian</title>
		<link>http://iPhoneDeveloperTips.com/c/working-with-bitfields.html/comment-page-1#comment-153</link>
		<dc:creator>Christian</dc:creator>
		<pubDate>Mon, 22 Dec 2008 16:03:51 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1373#comment-153</guid>
		<description>Very nice article!
This is a very clean and compact approach to a type of data structure I seem to find myself needing time and time again. Anxious to give it a go today!</description>
		<content:encoded><![CDATA[<p>Very nice article!<br />
This is a very clean and compact approach to a type of data structure I seem to find myself needing time and time again. Anxious to give it a go today!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rodney</title>
		<link>http://iPhoneDeveloperTips.com/c/working-with-bitfields.html/comment-page-1#comment-152</link>
		<dc:creator>Rodney</dc:creator>
		<pubDate>Mon, 22 Dec 2008 14:30:35 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1373#comment-152</guid>
		<description>Nice article.  I didn&#039;t realize that a struct could be use like this.  What I would like to know more about though, is how this could be applied to custom binary data downloaded via the network.  

Imagine a custom network protocol in which a sequence of bytes where downloaded and each byte had meaning.  How would one read those bytes?  I&#039;d assume you would start with NSData, convert that into a char[] and then create a pointer to move through the char array.  Each char, being one byte, would then need to be masked to get the value for a particular bit in the byte.

A good example of this applied is WBXML, which is a way to encode XML into a very compact binary protocol.  XML documents will, on average, will be 60% smaller when encoded as WBXML, which when gzip&#039;d on top of that you can get some amazing compression.</description>
		<content:encoded><![CDATA[<p>Nice article.  I didn&#8217;t realize that a struct could be use like this.  What I would like to know more about though, is how this could be applied to custom binary data downloaded via the network.  </p>
<p>Imagine a custom network protocol in which a sequence of bytes where downloaded and each byte had meaning.  How would one read those bytes?  I&#8217;d assume you would start with NSData, convert that into a char[] and then create a pointer to move through the char array.  Each char, being one byte, would then need to be masked to get the value for a particular bit in the byte.</p>
<p>A good example of this applied is WBXML, which is a way to encode XML into a very compact binary protocol.  XML documents will, on average, will be 60% smaller when encoded as WBXML, which when gzip&#8217;d on top of that you can get some amazing compression.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
