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

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

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

      1. C/C++ 中的 long long

        long long in C/C++(C/C++ 中的 long long)
            <tbody id='LesZ5'></tbody>

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

                1. <small id='LesZ5'></small><noframes id='LesZ5'>

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

                  问题描述

                  我正在 GNU 的 C++ 编译器上尝试此代码,但无法理解其行为:

                  I am trying this code on GNU's C++ compiler and am unable to understand its behaviour:

                  #include <stdio.h>;
                  
                  int main()
                  {
                      int  num1 = 1000000000;
                      long num2 = 1000000000;
                      long long num3;
                      //num3 = 100000000000;
                      long long num4 = ~0;
                  
                      printf("%u %u %u", sizeof(num1), sizeof(num2), sizeof(num3));
                      printf("%d %ld %lld %llu", num1, num2, num3, num4);
                      return 0;
                  }
                  

                  当我取消注释注释行时,代码无法编译并给出错误:

                  When I uncomment the commented line, the code doesn't compile and is giving an error:

                  错误:整数常量对于长类型来说太大

                  error: integer constant is too large for long type

                  但是,如果代码按原样编译并执行,它会产生远大于 10000000000 的值.

                  But, if the code is compiled as it is and is executed, it produces values much larger than 10000000000.

                  为什么?

                  推荐答案

                  字母 100000000000 组成了一个文字整数常量,但对于 int 类型来说该值太大了.您需要使用后缀来更改文字的类型,即

                  The letters 100000000000 make up a literal integer constant, but the value is too large for the type int. You need to use a suffix to change the type of the literal, i.e.

                  long long num3 = 100000000000LL;
                  

                  后缀LL 使文字变成long long 类型.C 不够聪明",无法从左侧的类型得出结论,类型是文字本身的属性,而不是使用它的上下文.

                  The suffix LL makes the literal into type long long. C is not "smart" enough to conclude this from the type on the left, the type is a property of the literal itself, not the context in which it is being used.

                  这篇关于C/C++ 中的 long long的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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?)
                    <tbody id='lKe9w'></tbody>
                      <bdo id='lKe9w'></bdo><ul id='lKe9w'></ul>
                      <tfoot id='lKe9w'></tfoot>

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

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