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

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

  2. <tfoot id='zxJrW'></tfoot>

    <legend id='zxJrW'><style id='zxJrW'><dir id='zxJrW'><q id='zxJrW'></q></dir></style></legend>

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

      numeric_limits<double>::digits10是什么意思

      时间:2024-05-11
      <legend id='Cuyvy'><style id='Cuyvy'><dir id='Cuyvy'><q id='Cuyvy'></q></dir></style></legend>
      <i id='Cuyvy'><tr id='Cuyvy'><dt id='Cuyvy'><q id='Cuyvy'><span id='Cuyvy'><b id='Cuyvy'><form id='Cuyvy'><ins id='Cuyvy'></ins><ul id='Cuyvy'></ul><sub id='Cuyvy'></sub></form><legend id='Cuyvy'></legend><bdo id='Cuyvy'><pre id='Cuyvy'><center id='Cuyvy'></center></pre></bdo></b><th id='Cuyvy'></th></span></q></dt></tr></i><div id='Cuyvy'><tfoot id='Cuyvy'></tfoot><dl id='Cuyvy'><fieldset id='Cuyvy'></fieldset></dl></div>
        • <bdo id='Cuyvy'></bdo><ul id='Cuyvy'></ul>

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

                  <tbody id='Cuyvy'></tbody>

              1. <tfoot id='Cuyvy'></tfoot>
                本文介绍了numeric_limits<double>::digits10是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                numeric_limits::digits10 的确切含义是什么?stackoverflow 中的一些其他相关问题让我认为它是双精度的最大精度,但是

                What is the precise meaning of numeric_limits::digits10? Some other related questions in stackoverflow made me think it is the maximum precision of a double, but

                • 当精度大于 17 ( == 2+numeric_limits::digits10) 时,以下原型开始工作(成功为真)
                • 使用STLPort,最后readDouble==infinity;使用微软的 STL,readDouble == 0.0.
                • 这个原型有什么意义吗:)?

                这是原型:

                #include <float.h>
                #include <limits>
                #include <math.h>
                #include <iostream>
                #include <iomanip>
                #include <sstream>
                #include <string>
                int main(int argc, const char* argv[]) {
                  std::ostringstream os;
                  //int digit10=std::numeric_limits<double>::digits10; // ==15
                  //int digit=std::numeric_limits<double>::digits; // ==53
                  os << std::setprecision(17);
                  os << DBL_MAX;
                  std::cout << os.str();
                  std::stringbuf sb(os.str());
                  std::istream is(&sb);
                  double readDouble=0.0;
                  is >> readDouble;
                  bool success = fabs(DBL_MAX-readDouble)<0.1;
                }
                

                推荐答案

                numeric_limits::digits10 是可以不丢失的小数位数.

                numeric_limits::digits10 is the number of decimal digits that can be held without loss.

                例如 numeric_limits::digits10 是 2.这意味着无符号字符可以保持 0..99 而不会丢失.如果是 3,它可以容纳 0..999,但众所周知,它只能容纳 0..255.

                For example numeric_limits<unsigned char>::digits10 is 2. This means that an unsigned char can hold 0..99 without loss. If it were 3 it could hold 0..999, but as we all know it can only hold 0..255.

                本手册页有一个浮点数示例,其中(缩短时)表明

                This manual page has an example for floating point numbers, which (when shortened) shows that

                cout << numeric_limits<float>::digits10 <<endl;
                float f = (float)99999999; // 8 digits
                cout.precision ( 10 );
                cout << "The float is; " << f << endl;
                

                印刷品

                6
                The float is; 100000000
                

                这篇关于numeric_limits<double>::digits10是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:为什么 std::string 不提供到 char* 的隐式转换? 下一篇:std::stack 是否公开迭代器?

                相关文章

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