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

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

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

      <bdo id='w9m7L'></bdo><ul id='w9m7L'></ul>
    <legend id='w9m7L'><style id='w9m7L'><dir id='w9m7L'><q id='w9m7L'></q></dir></style></legend>

    1. 如何將浮點數保存為 2 個字節?

      How do I save a floating-point number in 2 bytes?(如何將浮點數保存為 2 個字節?)

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

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

              <bdo id='l15KC'></bdo><ul id='l15KC'></ul>
                本文介紹了如何將浮點數保存為 2 個字節?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                是的,我知道 IEEE-754 半精度標準,是的,我知道在該領域所做的工作.簡而言之,我試圖將一個簡單的浮點數(如 52.11.25)保存在 2 個字節中.

                Yes I'm aware of the IEEE-754 half-precision standard, and yes I'm aware of the work done in the field. Put very simply, I'm trying to save a simple floating point number (like 52.1, or 1.25) in just 2 bytes.

                我在 Java 和 C# 但它們通過解碼不同的數字來破壞輸入值.您輸入 32.1 并在編碼解碼后得到 32.0985.

                I've tried some implementations in Java and in C# but they ruin the input value by decoding a different number. You feed in 32.1 and after encode-decode you get 32.0985.

                有什么方法可以在不破壞輸入值的情況下以 16 位存儲浮點數?

                Is there ANY way I can store floating point numbers in just 16-bits without ruining the input value?

                非常感謝.

                推薦答案

                您可以將三位數字存儲為 BCD 并使用剩余的四位作為小數點位置:

                You could store three digits in BCD and use the remaining four bits for the decimal point position:

                52.1 = 521 * 10 ^ -1 => 0x1521
                1.25 = 125 * 10 ^ -2 => 0x2125
                

                這將為您提供從 0.0000000000000001 到 999 的范圍.當然,您可以為小數點添加偏移量,例如范圍為 0.0000000001 到 999000000.

                This would give you a range from 0.0000000000000001 to 999. You can of course add an offset for the decimal point to get for example the range 0.0000000001 to 999000000.

                四位用于小數點放置的簡單實現,其余用于值.沒有任何錯誤檢查,也沒有徹底檢查.(使用 != 比較雙精度時,某些值可能存在精度問題.)

                Simple implementation of four bit used for decimal point placement, and the rest for the value. Without any error check, and not thoroughly checked. (May have precision issues with some values when using != to compare doubles.)

                public static short Encode(double value) {
                  int cnt = 0;
                  while (value != Math.Floor(value)) {
                    value *= 10.0;
                    cnt++;
                  }
                  return (short)((cnt << 12) + (int)value);
                }
                
                public static double Decode(short value) {
                  int cnt = value >> 12;
                  double result = value & 0xfff;
                  while (cnt > 0) {
                    result /= 10.0;
                    cnt--;
                  }
                  return result;
                }
                

                例子:

                Console.WriteLine(Encode(52.1));
                Console.WriteLine(Decode(4617));
                

                輸出:

                4617
                52.1
                

                這篇關于如何將浮點數保存為 2 個字節?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運行總 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(從函數調用按鈕 OnClick)
                  <legend id='74DyU'><style id='74DyU'><dir id='74DyU'><q id='74DyU'></q></dir></style></legend>

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

                      1. <small id='74DyU'></small><noframes id='74DyU'>

                          <bdo id='74DyU'></bdo><ul id='74DyU'></ul>
                        • <tfoot id='74DyU'></tfoot>
                          主站蜘蛛池模板: 免费在线一区二区三区 | 久久免费精品视频 | 久久爆操 | 欧美在线观看网站 | 精品久久久久久亚洲精品 | 综合国产第二页 | 91精品国产色综合久久 | 欧美一区二区在线 | 欧美日韩国产一区二区三区 | 成人免费大片黄在线播放 | 日韩成人在线网站 | 青青久在线视频 | 国产一区二区在线播放视频 | 欧美一区免费 | 二区在线视频 | 天天操天天干天天透 | 中文字幕精品一区二区三区精品 | 亚洲久久 | 91久久| 亚洲一级视频在线 | 欧美日韩在线播放 | 日本一二区视频 | 隔壁老王国产在线精品 | 成人亚洲一区 | 久久久国产精品一区 | 91深夜福利视频 | 日韩成人av在线播放 | 一区二区三区四区日韩 | 中文字幕在线观看一区二区 | 91av免费版| 999久久久 | 毛片一级黄色 | av永久 | 国产精品久久9 | 欧美一级精品片在线看 | 成人久草 | 综合国产 | 国产高清视频在线 | 精品国产一区二区三区免费 | 日韩成人免费视频 | 精品一区国产 |