• <small id='qrNGs'></small><noframes id='qrNGs'>

  • <tfoot id='qrNGs'></tfoot>
        <legend id='qrNGs'><style id='qrNGs'><dir id='qrNGs'><q id='qrNGs'></q></dir></style></legend>

      1. <i id='qrNGs'><tr id='qrNGs'><dt id='qrNGs'><q id='qrNGs'><span id='qrNGs'><b id='qrNGs'><form id='qrNGs'><ins id='qrNGs'></ins><ul id='qrNGs'></ul><sub id='qrNGs'></sub></form><legend id='qrNGs'></legend><bdo id='qrNGs'><pre id='qrNGs'><center id='qrNGs'></center></pre></bdo></b><th id='qrNGs'></th></span></q></dt></tr></i><div id='qrNGs'><tfoot id='qrNGs'></tfoot><dl id='qrNGs'><fieldset id='qrNGs'></fieldset></dl></div>

          <bdo id='qrNGs'></bdo><ul id='qrNGs'></ul>

        .NET 十进制的二进制表示

        时间:2023-06-03

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

          • <tfoot id='EMvEj'></tfoot>
          • <i id='EMvEj'><tr id='EMvEj'><dt id='EMvEj'><q id='EMvEj'><span id='EMvEj'><b id='EMvEj'><form id='EMvEj'><ins id='EMvEj'></ins><ul id='EMvEj'></ul><sub id='EMvEj'></sub></form><legend id='EMvEj'></legend><bdo id='EMvEj'><pre id='EMvEj'><center id='EMvEj'></center></pre></bdo></b><th id='EMvEj'></th></span></q></dt></tr></i><div id='EMvEj'><tfoot id='EMvEj'></tfoot><dl id='EMvEj'><fieldset id='EMvEj'></fieldset></dl></div>
            • <bdo id='EMvEj'></bdo><ul id='EMvEj'></ul>
              <legend id='EMvEj'><style id='EMvEj'><dir id='EMvEj'><q id='EMvEj'></q></dir></style></legend>

                  <tbody id='EMvEj'></tbody>
                  本文介绍了.NET 十进制的二进制表示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  .NET decimal 类型如何在内存中以二进制形式表示?

                  How does a .NET decimal type get represented in binary in memory?

                  我们都知道浮点数是如何存储的,也知道浮点数不准确的原因,但除了以下内容,我找不到任何关于 decimal 的信息:

                  We all know how floating-point numbers are stored and the thusly the reasons for the inaccuracy thereof, but I can't find any information about decimal except the following:

                  1. 显然比浮点数更准确
                  2. 占用 128 位内存
                  3. 2^96 + 符号范围
                  4. 28(有时是 29?)总有效位数

                  有什么办法可以解决这个问题吗?我内心的计算机科学家要求答案,经过一个小时的尝试研究,我找不到答案.似乎要么有很多浪费的位,要么我只是在脑海中想象这个错误.有人能解释一下吗?

                  Is there any way I can figure this out? The computer scientist in me demands the answer and after an hour of attempted research, I cannot find it. It seems like there's either a lot of wasted bits or I'm just picturing this wrong in my head. Can anyone shed some light on this please?

                  推荐答案

                  Decimal.GetBits 获取您想要的信息.

                  Decimal.GetBits for the information you want.

                  基本上它是一个 96 位整数作为尾数,加上一个符号位,再加上一个指数,表示将其向右移动多少个小数位.

                  Basically it's a 96 bit integer as the mantissa, plus a sign bit, plus an exponent to say how many decimal places to shift it to the right.

                  因此,要表示 3.261,您的尾数为 3261,符号位为 0(即正数),指数为 3.请注意,十进制没有(故意)标准化,因此您可以 例如,使用尾数 32610 和指数 4 来表示 3.2610.

                  So to represent 3.261 you'd have a mantissa of 3261, a sign bit of 0 (i.e. positive), and an exponent of 3. Note that decimal isn't normalized (deliberately) so you can also represent 3.2610 by using a mantissa of 32610 and an exponent of 4, for example.

                  我在关于十进制浮点数的文章中有更多信息.

                  I have some more information in my article on decimal floating point.

                  这篇关于.NET 十进制的二进制表示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 C# 中获取浮点数的 IEEE 754 二进制表示 下一篇:C# BinaryFormatter - 使用另一个命名空间中的对象反

                  相关文章

                  最新文章

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

                    <tfoot id='cbvUr'></tfoot>
                    • <bdo id='cbvUr'></bdo><ul id='cbvUr'></ul>

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

                    1. <legend id='cbvUr'><style id='cbvUr'><dir id='cbvUr'><q id='cbvUr'></q></dir></style></legend>