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

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

      <legend id='MIi5p'><style id='MIi5p'><dir id='MIi5p'><q id='MIi5p'></q></dir></style></legend>
    1. Cout 长双发行

      时间:2023-08-27
        <i id='Vo1Q5'><tr id='Vo1Q5'><dt id='Vo1Q5'><q id='Vo1Q5'><span id='Vo1Q5'><b id='Vo1Q5'><form id='Vo1Q5'><ins id='Vo1Q5'></ins><ul id='Vo1Q5'></ul><sub id='Vo1Q5'></sub></form><legend id='Vo1Q5'></legend><bdo id='Vo1Q5'><pre id='Vo1Q5'><center id='Vo1Q5'></center></pre></bdo></b><th id='Vo1Q5'></th></span></q></dt></tr></i><div id='Vo1Q5'><tfoot id='Vo1Q5'></tfoot><dl id='Vo1Q5'><fieldset id='Vo1Q5'></fieldset></dl></div>
          <tbody id='Vo1Q5'></tbody>
      • <legend id='Vo1Q5'><style id='Vo1Q5'><dir id='Vo1Q5'><q id='Vo1Q5'></q></dir></style></legend>

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

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

            <tfoot id='Vo1Q5'></tfoot>

                本文介绍了Cout 长双发行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                所以,我正在做一个 C++ 项目.我有一个 long double 类型的 var 并为其分配了一个类似1.02"的值

                So, I'm working on a C++ project. I have a var of long double type and assigned it a value like "1.02"

                然后,我尝试用cout打印出来,结果是:-0

                Then, I try to use cout to print it and the result is: -0

                我已经尝试使用 setprecision 并且我在谷歌搜索中发现了所有问题.

                I already tried to use setprecision and all I found googling the problem.

                对此有什么解决方案?

                示例代码:

                #include <cstdlib>
                #include <iomanip>
                
                using namespace std;
                
                int main(int argc, char** argv)
                {
                
                    cout.precision(15);
                    long double var = 1.2;
                    cout << var << endl;
                    return 0;
                }
                

                操作系统:Windows 8.1 64 位编译器:minGWIDE:NetBeans 8.0.2

                OS: Windows 8.1 64 bits Compiler: minGW IDE: NetBeans 8.0.2

                推荐答案

                似乎是编译器的问题.看看这里:http://mingw.5.n7.nabble.com/Strange-behaviour-of-gcc-4-8-1-with-long-double-td32949.html

                It seems to be a problem with compiler. Take a look here: http://mingw.5.n7.nabble.com/Strange-behaviour-of-gcc-4-8-1-with-long-double-td32949.html

                使用 printf 或在传递给 cout 之前将变量的值转换为 double.(顺便说一句,您确定需要 80 位精度吗?)

                Use printf or convert a value of your variable to double before passing to cout. (BTW are sure you need 80-bit precision?)

                这篇关于Cout 长双发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Qt Designer,缺少“转到插槽"在上下文菜单中? 下一篇:在 NetBeans 中集成 Clang?

                相关文章

              1. <legend id='ejg0j'><style id='ejg0j'><dir id='ejg0j'><q id='ejg0j'></q></dir></style></legend>
                • <bdo id='ejg0j'></bdo><ul id='ejg0j'></ul>
                  <tfoot id='ejg0j'></tfoot>

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

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