<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 长双发行

      Cout long double issue(Cout 长双发行)
        <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 长双发行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                Delay Loading DLLs(延迟加载 DLL)
                Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                Loading a dll from a dll?(从 dll 加载 dll?)
                • <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'>

                          <tbody id='ejg0j'></tbody>

                        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>