久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <small id='rKDrk'></small><noframes id='rKDrk'>

      1. <legend id='rKDrk'><style id='rKDrk'><dir id='rKDrk'><q id='rKDrk'></q></dir></style></legend>
        • <bdo id='rKDrk'></bdo><ul id='rKDrk'></ul>
      2. <i id='rKDrk'><tr id='rKDrk'><dt id='rKDrk'><q id='rKDrk'><span id='rKDrk'><b id='rKDrk'><form id='rKDrk'><ins id='rKDrk'></ins><ul id='rKDrk'></ul><sub id='rKDrk'></sub></form><legend id='rKDrk'></legend><bdo id='rKDrk'><pre id='rKDrk'><center id='rKDrk'></center></pre></bdo></b><th id='rKDrk'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rKDrk'><tfoot id='rKDrk'></tfoot><dl id='rKDrk'><fieldset id='rKDrk'></fieldset></dl></div>
        <tfoot id='rKDrk'></tfoot>

        我如何編碼一串 1 和 0 用于傳輸?

        How could I encode a string of 1s and 0s for transport?(我如何編碼一串 1 和 0 用于傳輸?)

        <small id='cuhdP'></small><noframes id='cuhdP'>

      3. <i id='cuhdP'><tr id='cuhdP'><dt id='cuhdP'><q id='cuhdP'><span id='cuhdP'><b id='cuhdP'><form id='cuhdP'><ins id='cuhdP'></ins><ul id='cuhdP'></ul><sub id='cuhdP'></sub></form><legend id='cuhdP'></legend><bdo id='cuhdP'><pre id='cuhdP'><center id='cuhdP'></center></pre></bdo></b><th id='cuhdP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cuhdP'><tfoot id='cuhdP'></tfoot><dl id='cuhdP'><fieldset id='cuhdP'></fieldset></dl></div>

          <tbody id='cuhdP'></tbody>
            <bdo id='cuhdP'></bdo><ul id='cuhdP'></ul>

                  <tfoot id='cuhdP'></tfoot>
                  <legend id='cuhdP'><style id='cuhdP'><dir id='cuhdP'><q id='cuhdP'></q></dir></style></legend>
                  本文介紹了我如何編碼一串 1 和 0 用于傳輸?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  對于遺傳算法應(yīng)用程序,我使用了一整套二進(jìn)制字符串.大多數(shù)情況下,它們實(shí)際上采用 01001010110 的形式,以便它們可以交配、變異和交叉".

                  For a genetic algorithm application, I'm using a whole load of binary strings. Most of the time they literally take the form of 01001010110, so that they can be mated, mutated and "crossed-over".

                  然而,對于運(yùn)輸和存儲來說,這似乎是一種浪費(fèi).將其編碼為較短字符串的最簡單方法是什么?

                  For transport and storage however, this seems wasteful. What's the simplest way to encode this as a shorter string?

                  我猜這很簡單,但我不確定從哪里開始.

                  I'm guessing this is pretty trivial, but I'm not sure where to start looking.

                  更新:我實(shí)際上需要以另一個字符串結(jié)尾:其中一個傳輸請求將是 GET 請求.

                  Update: I actually need to end up with another string: one of the transport requests will be GET requests.

                  推薦答案

                  最簡單的方法是取每個數(shù)字并將其視為一個位.每組 8 位可以存儲在一個字節(jié)中.然后您可以將其作為字節(jié)流發(fā)送.您還需要存儲原始字符串的長度,以便區(qū)分0"和00".

                  The simplest would be to take each digit and treat it as a bit. Each group of 8 bits can be stored in a byte. Then you can send it as a stream of bytes. You will also need to store the length of the original string so that you can distinguish between "0" and "00".

                  這是一種將字符串轉(zhuǎn)換為字節(jié)數(shù)組的方法:

                  Here is one way you could write the conversion from string to a byte array:

                  byte[] convertToBytes(string s)
                  {
                      byte[] result = new byte[(s.Length + 7) / 8];
                  
                      int i = 0;
                      int j = 0;
                      foreach (char c in s)
                      {
                          result[i] <<= 1;
                          if (c == '1')
                              result[i] |= 1;
                          j++;
                          if (j == 8)
                          {
                              i++;
                              j = 0;
                          }
                      }
                      return result;
                  }
                  

                  反轉(zhuǎn)操作非常相似.

                  如果您需要將數(shù)據(jù)作為字符串傳輸,您可以base 64 編碼 得到的字節(jié)數(shù)組.

                  If you need to transmit the data as a string you can base 64 encode the resulting byte array.

                  您可能還想考慮將它以這種形式保存在內(nèi)存中.這將比將其存儲為每個數(shù)字存儲為 2 字節(jié)字符的字符串更有效.您使用的內(nèi)存大約是存儲數(shù)據(jù)所需的 16 倍.缺點(diǎn)是這種形式使用起來稍微困難一些,所以如果你有足夠的內(nèi)存,那么你現(xiàn)在正在做的事情可能就可以了.

                  You may also want to consider keeping it in this form in memory too. This will be much more efficient than storing it as a string where each digit is stored as a 2 byte character. You are using roughly 16 times more memory than you need to for storing your data. The disadvtange is that it is slightly more difficult to use in this form, so if you have enough memory then what you are currently doing might be just fine.

                  這篇關(guān)于我如何編碼一串 1 和 0 用于傳輸?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運(yùn)行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)
                  <i id='xDmhM'><tr id='xDmhM'><dt id='xDmhM'><q id='xDmhM'><span id='xDmhM'><b id='xDmhM'><form id='xDmhM'><ins id='xDmhM'></ins><ul id='xDmhM'></ul><sub id='xDmhM'></sub></form><legend id='xDmhM'></legend><bdo id='xDmhM'><pre id='xDmhM'><center id='xDmhM'></center></pre></bdo></b><th id='xDmhM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xDmhM'><tfoot id='xDmhM'></tfoot><dl id='xDmhM'><fieldset id='xDmhM'></fieldset></dl></div>

                    <small id='xDmhM'></small><noframes id='xDmhM'>

                    • <bdo id='xDmhM'></bdo><ul id='xDmhM'></ul>

                            <tbody id='xDmhM'></tbody>

                            <legend id='xDmhM'><style id='xDmhM'><dir id='xDmhM'><q id='xDmhM'></q></dir></style></legend>
                            <tfoot id='xDmhM'></tfoot>
                            主站蜘蛛池模板: 国产精品视频一区二区三区四区国 | 日韩精品av | 久久久91 | 久久精品亚洲精品国产欧美 | 成人免费大片黄在线播放 | 97色在线视频 | 欧洲妇女成人淫片aaa视频 | jav成人av免费播放 | 中日字幕大片在线播放 | 黄色在线观看网址 | 欧美性网站 | 亚洲精品日日夜夜 | 亚洲一区电影 | 欧美日韩精品在线一区 | 亚洲一区二区在线电影 | 一级黄a视频 | 国产精品毛片 | 欧美日高清视频 | 日韩精品在线免费观看 | 日本激情一区二区 | 精品久久久网站 | 国产一区二区免费电影 | 日本三级在线视频 | 99久久婷婷国产综合精品 | 九九一级片 | 亚洲性人人天天夜夜摸 | 色站综合 | 欧美专区在线 | av中文在线播放 | 精品久久久久久亚洲精品 | a级黄色片在线观看 | 欧美日韩亚 | 国产精品欧美一区二区三区不卡 | 亚洲国产欧美91 | 欧美视频二区 | 四虎影院在线播放 | 天堂网中文字幕在线观看 | 国产欧美精品一区二区色综合 | 国产一区二区三区 | 国产一区二区中文字幕 | 爱爱无遮挡 |