<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218644</guid>
        <pubDate>Fri, 01 Nov 2002 08:50:21 +0000</pubDate>
        <title>Как вернуть и задать значение бита в байте</title>
        <link>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218644</link>
        <description><![CDATA[NEO_BEST: Всем огромаднейшее ШПАСИБО !]]></description>
        <author>NEO_BEST</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218643</guid>
        <pubDate>Fri, 01 Nov 2002 08:34:09 +0000</pubDate>
        <title>Как вернуть и задать значение бита в байте</title>
        <link>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218643</link>
        <description><![CDATA[www: Блин, пока писал свой ответ, двое папиков уже ответили... :)]]></description>
        <author>www</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218642</guid>
        <pubDate>Fri, 01 Nov 2002 08:30:18 +0000</pubDate>
        <title>Как вернуть и задать значение бита в байте</title>
        <link>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218642</link>
        <description><![CDATA[www: Ответ содержиться в самом вопросе (0&#124;1) ;)<br><br>void SetBit(DWORD&amp; dw, int nBitNumber, int nBitValue)<br>{<br> &nbsp; &nbsp; &nbsp;//dw - целое, в котором задаем бит<br> &nbsp; &nbsp; &nbsp;//nBitNumber - номер бита, который задаем (0..31)<br> &nbsp; &nbsp; &nbsp;DWORD dwMask = 1 &lt;&lt; nBitNumber;// 0000100000....<br> &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp;//nBitValue (0&#124;1)<br> &nbsp; &nbsp; &nbsp;if(nBitValue == 0)<br> &nbsp; &nbsp; &nbsp;{//задаем 0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwMask = ~dwMask;// 1111011111....<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dw = dw &amp; dwMask; // 0 &amp; x = 0<br> &nbsp; &nbsp; &nbsp;}<br> &nbsp; &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp;{//задаем 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dw = dw &#124; dwMask;// 1 &#124; x = 1<br> &nbsp; &nbsp; &nbsp;}<br>}<br><br>int GetBit(DWORD dw, int nBitNumber)<br>{<br> &nbsp; &nbsp; &nbsp;//dw - целое в котором узнаем бит<br> &nbsp; &nbsp; &nbsp;//nBitNumber - номер бита, который узнаем (0..31)<br> &nbsp; &nbsp; &nbsp;DWORD dwMask = 1 &lt;&lt; nBitNumber;// 0000100000....<br> &nbsp; &nbsp; &nbsp;dw = dwMask &amp; dw;<br> &nbsp; &nbsp; &nbsp;if(dw)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return 1;<br> &nbsp; &nbsp; &nbsp;return 0;<br>}<br><br>Использование:<br><br> &nbsp; &nbsp; &nbsp;DWORD dw = 1;<br> &nbsp; &nbsp; &nbsp;GetBit(dw, 1);// == 0<br> &nbsp; &nbsp; &nbsp;SetBit(dw, 0, 0);// dw == 0<br> &nbsp; &nbsp; &nbsp;SetBit(dw, 1, 1);//dw == 2<br> &nbsp; &nbsp; &nbsp;GetBit(dw, 1);// == 1<br>]]></description>
        <author>www</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218641</guid>
        <pubDate>Fri, 01 Nov 2002 08:07:08 +0000</pubDate>
        <title>Как вернуть и задать значение бита в байте</title>
        <link>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218641</link>
        <description><![CDATA[Alch: Наверно, так :)<br><br><div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&#60;br&#62;BOOL BitSetted (long n, char i) // (n - число, i - бит начиная с нуля)&#60;br&#62;{&#60;br&#62; &nbsp; &nbsp; return (n &#62;&#62; i) &amp; 1;&#60;br&#62;}&#60;br&#62;&#60;br&#62;long SetBitToOne (long n, char i)&#60;br&#62;{&#60;br&#62; &nbsp; &nbsp; return n | (1 &#60;&#60; i);&#60;br&#62;}&#60;br&#62;&#60;br&#62;long SetBitToZero (long n, char i)&#60;br&#62;{&#60;br&#62; &nbsp; &nbsp; return n &amp; ~(1 &#60;&#60; i);&#60;br&#62;}&#60;br&#62;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br><br>Ты это имел ввиду?]]></description>
        <author>Alch</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218640</guid>
        <pubDate>Fri, 01 Nov 2002 08:05:54 +0000</pubDate>
        <title>Как вернуть и задать значение бита в байте</title>
        <link>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218640</link>
        <description><![CDATA[J0ker: Есть байт. Выбираем нужное место в нем, для примера, второй бит.<br>Чтобы установить его, делаем так: byte &#124;= 0x04 (это 00000100b)<br>Чтобы сбросить: byte &amp;= 0xFB (это 11111011b)<br>Чтобы узнать, установлен ли бит: &nbsp;<br>if (byte &amp; 0x04) бит_установлен; else бит_не_установлен.<br><br>Можно это все сделать автоматически сдвигами. Если надо - обращайся.]]></description>
        <author>J0ker</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218639</guid>
        <pubDate>Fri, 01 Nov 2002 07:53:16 +0000</pubDate>
        <title>Как вернуть и задать значение бита в байте</title>
        <link>https://forum.sources.ru/index.php?showtopic=32992&amp;view=findpost&amp;p=218639</link>
        <description><![CDATA[NEO_BEST: Подскажите как мне получить значение бита в байте...и как установить определённый бит в байте в определённое значение (1 &#124; 0 ) ?]]></description>
        <author>NEO_BEST</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      </channel>
      </rss>
	