{"id":156021,"date":"2013-07-02T11:15:05","date_gmt":"2013-07-02T07:15:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=156021"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=156021","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438 \u0432 \u044f\u0437\u044b\u043a\u0435 C#<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0432 \u0445\u043e\u0434\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430. \u0425\u043e\u0440\u043e\u0448\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0435\u0441\u043b\u0438 \u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u0438 8, 16, 32 \u0438\u043b\u0438 64-\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0438\u043b\u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0437\u0443 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u0441\u0442\u0438 (\u043e\u0442 2 \u0434\u043e 64 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e, \u0442.\u0435., \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 8 \u0431\u0430\u0439\u0442\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f 2 \u0447\u0438\u0441\u043b\u0430, \u043f\u0435\u0440\u0432\u043e\u0435 \u0441 0 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u043f\u043e 28, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u0441 29 \u043f\u043e 63 \u0440\u0430\u0437\u0440\u044f\u0434\u044b, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435).\u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043c\u043e\u0438 \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u0435 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438-\u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430\u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443, \u0447\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0430\u043c\u043e\u043c\u0443 \u0440\u0435\u0448\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. <\/p>\n<p>  \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432 (\u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0442\u043e\u0432\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432 \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 BitArray, \u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443), \u0435\u0449\u0435 \u0438\u043c\u0435\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0438\u0442\u043e\u0432.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0438\u043c\u0435\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430 \u043f\u043b\u0435\u0447\u0430\u043c\u0438, \u044f \u0440\u0435\u0448\u0438\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0431\u0438\u0442\u043e\u0432, \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b 2 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 GetBit\u0438 SetBit, \u043f\u0435\u0440\u0432\u044b\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0431\u0430\u0439\u0442 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0431\u0438\u0442\u0430 \u0438, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0430\u043c \u043d\u043e\u043c\u0435\u0440 \u0431\u0438\u0442\u0430, \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0431\u0438\u0442\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0431\u0443\u043b\u0435\u0432\u0441\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430:<\/p>\n<pre><code class=\"cs\">\/\/\/&lt;summary&gt; \/\/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u0438\u0442 \u0432 num \u0431\u0430\u0439\u0442\u0435 val \/\/\/&lt;\/summary&gt; \/\/\/&lt;param name=&quot;val&quot;&gt;\u0412\u0445\u043e\u0434\u043d\u043e\u0439\u0431\u0430\u0439\u0442&lt;\/param&gt; \/\/\/&lt;param name=&quot;num&quot;&gt;\u041d\u043e\u043c\u0435\u0440\u0431\u0438\u0442\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u044f\u0441 0&lt;\/param&gt; \/\/\/&lt;returns&gt;true-\u0431\u0438\u0442\u0440\u0430\u0432\u0435\u043d 1, false- \u0431\u0438\u0442\u0440\u0430\u0432\u0435\u043d 0&lt;\/returns&gt; public static bool GetBit(byte val,int num) {           if ((num&gt; 7) || (num&lt; 0))\/\/\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445           {                throw new ArgumentException();            }      return ((val&gt;&gt;num)&1)&gt;0;\/\/\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f }  \/\/\/&lt;summary&gt; \/\/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0431\u0438\u0442\u0430 \u0432 \u0431\u0430\u0439\u0442\u0435 \/\/\/&lt;\/summary&gt; \/\/\/&lt;param name=&quot;val&quot;&gt;\u0412\u0445\u043e\u0434\u043d\u043e\u0439\u0431\u0430\u0439\u0442&lt;\/param&gt; \/\/\/&lt;param name=&quot;num&quot;&gt;\u041d\u043e\u043c\u0435\u0440\u0431\u0438\u0442\u0430&lt;\/param&gt; \/\/\/&lt;param name=&quot;bit&quot;&gt;\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u0431\u0438\u0442\u0430: true-\u0431\u0438\u0442\u0440\u0430\u0432\u0435\u043d 1, false- \u0431\u0438\u0442\u0440\u0430\u0432\u0435\u043d 0 &lt;\/param&gt; \/\/\/&lt;returns&gt;\u0411\u0430\u0439\u0442, \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0438\u0442\u0430&lt;\/returns&gt; public static byte SetBit(byte val, int num,bool bit) {             if ((num&gt; 7) || (num&lt; 0))\/\/\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445             {                throw new ArgumentException();             }   byte tmpval = 1;   tmpval = (byte)(tmpval&lt;&lt;num);\/\/\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u0431\u0438\u0442 \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443   val = (byte)(val& (~tmpval));\/\/\u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u043c \u0432 0 \u043d\u0443\u0436\u043d\u044b\u0439 \u0431\u0438\u0442             if (bit)\/\/ \u0435\u0441\u043b\u0438 \u0431\u0438\u0442 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 1             {                val = (byte)(val | (tmpval));\/\/\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0439 \u0431\u0438\u0442 \u0432 1             } return val;  }  <\/code><\/pre>\n<p>  \u041d\u0435 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044f\u0441\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u043c\u043e\u0434\u043d\u044b\u0445 \u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u043f\u043e \u0440\u0435\u0432\u0435\u0440\u0441\u0443 \u0431\u0438\u0442\u043e\u0432, \u0441\u0434\u0435\u043b\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cs\">\/\/\/&lt;summary&gt; \/\/\/ \u0418\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0438\u0442\u043e\u0432 \u043d\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \/\/\/&lt;\/summary&gt; \/\/\/&lt;param name=&quot;val&quot;&gt;\u0412\u0445\u043e\u0434\u043d\u043e\u0439\u0431\u0430\u0439\u0442&lt;\/param&gt; \/\/\/&lt;returns&gt;\u0411\u0430\u0439\u0442 \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u043c \u0431\u0438\u0442\u043e\u0432&lt;\/returns&gt; Public static byte Reverse(byte val)   {      int i = 0;      byterez = 0;       for (i = 0; i &lt; 8; i++)      {          rez = (byte)(rez&lt;&lt; 1);                if (((val&gt;&gt; i) & 1) &gt; 0)                 {                     rez = (byte)(rez | 1);                 }       }      return rez; }  <\/code><\/pre>\n<p>  \u041d\u043e \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u0435\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043a \u0432\u0438\u0434\u0443 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u043c\u0443 \u043c\u0430\u0448\u0438\u043d\u0435, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0431\u044b \u043e\u043d\u0438 \u0432\u0441\u0435 \u0431\u044b\u043b\u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e- \u0441\u0447\u0438\u0442\u0430\u043b \u043d\u0443\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442\u043e\u0432, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0438 \u043e\u0442\u0441\u0435\u043a \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0442\u044b, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0442\u0430\u043a \u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u044b\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0442.\u043a. \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0431\u0438\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u044f\u0442 \u043a\u0430\u043a \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0438 \u0447\u0438\u0441\u043b\u0430 \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"cs\">\/\/\/&lt;summary&gt; \/\/\/ \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 Int64, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0431\u0438\u0442\u0430 firstbit \u0438 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044f \u0431\u0438\u0442\u043e\u043c lastbit, \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0441\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \/\/\/&lt;\/summary&gt; \/\/\/&lt;paramname=&quot;bytes&quot;&gt;\u041c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u043e \u0441\u0442\u0430\u0440\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0447\u0438\u0441\u043b\u0430&lt;\/param&gt; \/\/\/&lt;param name=&quot;firstbit&quot;&gt;\u041c\u043b\u0430\u0434\u0448\u0438\u0439\u0431\u0438\u0442\u0447\u0438\u0441\u043b\u0430&lt;\/param&gt; \/\/\/&lt;param name=&quot;lastbit&quot;&gt;\u0421\u0442\u0430\u0440\u0448\u0438\u0439\u0431\u0438\u0442\u0447\u0438\u0441\u043b\u0430&lt;\/param&gt; \/\/\/&lt;paramname=&quot;issigned&quot;&gt;\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u043b\u0438 \u0447\u0438\u0441\u043b\u043e&lt;\/param&gt; \/\/\/&lt;returns&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f Int64&lt;\/returns&gt; public static Int64 HandleBytes(byte[] bytes, int firstbit, int lastbit,bool issigned)  {      if ((bytes == null) ||      (firstbit&lt; 0) ||      (firstbit&gt; 63) ||      (lastbit&lt; 0) ||      (lastbit&gt; 63) ||     (((lastbit - firstbit) == 63) && (!issigned)) ||\/\/\u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430 \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c 64-\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u0435, \u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 Int64    (bytes.Length&gt; 8) ||     (bytes.Length&lt; 1)||     (firstbit&gt;lastbit))        {             throw new ArgumentException();        }    Int64 rezult = 0,\/\/\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430    tmp = 0;\/\/\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439  \/\/\u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0431\u0430\u0439\u0442\u043e\u0432     foreach (byte tmp1 in bytes)     {        rezult = rezult&lt;&lt; 8;        rezult = rezult | tmp1;      }         rezult = rezult&gt;&gt;firstbit;\/\/\u043e\u0442\u0441\u0435\u043a\u0430\u0435\u043c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u043b\u0430\u0434\u0448\u0438\u0435\u0431\u0438\u0442\u044b       if (firstbit != lastbit)       {           tmp = (long)(Math.Pow(2, lastbit - firstbit));\/\/1 \u0432 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u043c \u0431\u0438\u0442\u0435, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 0           if ((issigned)&&((rezult&tmp)&gt;0))\/\/\u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e           {              \/\/\u044d\u0442\u043e \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u0430 \u0441\u0430\u043c\u0438 \u043f\u043e \u0441\u0435\u0431\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435               tmp = tmp - 1;\/\/\u0432\u0441\u0435 1 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043c\u043b\u0430\u0434\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0438 \u0434\u043e \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430, \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0431\u0438\u0442               rezult = ~rezult;\/\/ \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0442\u044b               rezult = rezult&tmp;\/\/ \u043e\u0442\u0441\u0435\u043a\u0430\u043c \u0441\u0442\u0430\u0440\u0448\u0438\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0442\u044b               rezult++;               rezult *=-1;              }           else\/\/ \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0438\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435, \u043d\u043e \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435            {             tmp = tmp + (tmp - 1);\/\/\u0432\u0441\u0435 1 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043c\u043b\u0430\u0434\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0438 \u0434\u043e \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0431\u0438\u0442\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0431\u0438\u0442             rezult = rezult&tmp;\/\/\u043e\u0442\u0441\u0435\u043a\u0430\u0435\u043c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0431\u0438\u0442\u044b             }          }       else\/\/\u0415\u0441\u043b\u0438 \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0438 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0438\u0442\u044b \u0440\u0430\u0432\u043d\u044b, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u0438\u0442       {           rezult = rezult& 1;        }    return rezult;  }  <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0430\u0439\u0442 \u043e\u0442 1 \u0434\u043e 8, \u0441\u0442\u0430\u0440\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432 0. firstbit \u2013\u043d\u043e\u043c\u0435\u0440 \u043c\u043b\u0430\u0434\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0447\u0438\u0441\u043b\u0430, lastbit \u2013\u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0430\u0440\u0448\u0435\u0433\u043e \u0431\u0438\u0442\u0430 \u0447\u0438\u0441\u043b\u0430, issigned- \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438\u043b\u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u0440\u044f\u0434\u0430\u0445 3-18, \u0442\u043e \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c HandleBytes(bytes, 3, 18,true).<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0435 3 \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438\u043c\u0435\u044e\u0442 \u0431\u0430\u0439\u0442, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0445\u043e\u0442\u044c \u043a\u043e\u043c\u0443-\u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0445\u043e\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/156021\/\"> http:\/\/habrahabr.ru\/post\/156021\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0443 \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0432 \u0445\u043e\u0434\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0437 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430. \u0425\u043e\u0440\u043e\u0448\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0435\u0441\u043b\u0438 \u0431\u044b \u044d\u0442\u043e \u0431\u044b\u043b\u0438 8, 16, 32 \u0438\u043b\u0438 64-\u0440\u0430\u0437\u0440\u044f\u0434\u043d\u044b\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0438\u043b\u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0437\u0443 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u0441\u0442\u0438 (\u043e\u0442 2 \u0434\u043e 64 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e, \u0442.\u0435., \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 8 \u0431\u0430\u0439\u0442\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c\u0441\u044f 2 \u0447\u0438\u0441\u043b\u0430, \u043f\u0435\u0440\u0432\u043e\u0435 \u0441 0 \u0440\u0430\u0437\u0440\u044f\u0434\u0430 \u043f\u043e 28, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u0441 29 \u043f\u043e 63 \u0440\u0430\u0437\u0440\u044f\u0434\u044b, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435).\u0415\u0441\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043c\u043e\u0438 \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u0435 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0438\u0442\u0430\u043c\u0438-\u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-156021","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/156021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=156021"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/156021\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=156021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=156021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=156021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}