久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

    1. 為什么long long n = 2000*2000*2000*2000;溢出?

      Why does long long n = 2000*2000*2000*2000; overflow?(為什么long long n = 2000*2000*2000*2000;溢出?)
      <i id='S6Kcq'><tr id='S6Kcq'><dt id='S6Kcq'><q id='S6Kcq'><span id='S6Kcq'><b id='S6Kcq'><form id='S6Kcq'><ins id='S6Kcq'></ins><ul id='S6Kcq'></ul><sub id='S6Kcq'></sub></form><legend id='S6Kcq'></legend><bdo id='S6Kcq'><pre id='S6Kcq'><center id='S6Kcq'></center></pre></bdo></b><th id='S6Kcq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='S6Kcq'><tfoot id='S6Kcq'></tfoot><dl id='S6Kcq'><fieldset id='S6Kcq'></fieldset></dl></div>

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

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

            <legend id='S6Kcq'><style id='S6Kcq'><dir id='S6Kcq'><q id='S6Kcq'></q></dir></style></legend>
            <tfoot id='S6Kcq'></tfoot>

                <tbody id='S6Kcq'></tbody>

                本文介紹了為什么long long n = 2000*2000*2000*2000;溢出?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                long long int n = 2000*2000*2000*2000;    // overflow
                
                long long int n = pow(2000,4);            // works
                long long int n = 16000000000000;         // works
                

                為什么第一個溢出(乘以整數文字常量以分配給 long long)?

                Why does the first one overflow (multiplying integer literal constants to assign to a long long)?

                它與第二個或第三個有什么不同?

                What's different about it vs. the second or third ones?

                推薦答案

                因為 2000 是一個 int 通常是 32 位的.只需使用 2000LL.

                Because 2000 is an int which is usually 32-bit. Just use 2000LL.

                使用 LL 后綴代替 ll 是@AdrianMole 在評論中建議的,現在已刪除.請查看他的答案.

                Using LL suffix instead of ll was suggested by @AdrianMole in, now deleted, comment. Please check his answer.

                默認情況下,整數文字是可以保存其值但不小于 int 的最小類型.2000 可以很容易地存儲在 int 中,因為標準保證它至少是一個有效的 16 位類型.

                By default, integer literals are of the smallest type that can hold their value but not smaller than int. 2000 can easily be stored in an int since the Standard guarantees it is effectively at least a 16-bit type.

                算術運算符總是使用存在的較大但不小于 int 的類型調用:

                Arithmetic operators are always called with the larger of the types present but not smaller than int:

                • char*char 將被提升為 operator*(int,int)->int
                • char*int 調用 operator*(int,int)->int
                • long*int 調用 operator*(long,long)->long
                • int*int 仍然調用 operator*(int,int)->int.
                • char*char will be promoted to operator*(int,int)->int
                • char*int calls operator*(int,int)->int
                • long*int calls operator*(long,long)->long
                • int*int still calls operator*(int,int)->int.

                至關重要的是,類型不依賴于結果是否可以存儲在推斷類型中.這正是您的情況發生的問題 - 乘法是用 ints 完成的,但結果溢出,因為它仍然存儲為 int.

                Crucially, the type is not dependent on whether the result can be stored in the inferred type. Which is exactly the problem happening in your case - multiplication is done with ints but the result overflows as it is still stored as int.

                C++ 不支持像 Haskell 那樣基于目的地推斷類型,因此賦值無關緊要.

                C++ does not support inferring types based on their destination like Haskell does so the assignment is irrelevant.

                這篇關于為什么long long n = 2000*2000*2000*2000;溢出?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                In what ways do C++ exceptions slow down code when there are no exceptions thown?(當沒有異常時,C++ 異常會以何種方式減慢代碼速度?)
                Why catch an exception as reference-to-const?(為什么要捕獲異常作為對 const 的引用?)
                When and how should I use exception handling?(我應該何時以及如何使用異常處理?)
                Scope of exception object in C++(C++中異常對象的范圍)
                Catching exceptions from a constructor#39;s initializer list(從構造函數的初始化列表中捕獲異常)
                Difference between C++03 throw() specifier C++11 noexcept(C++03 throw() 說明符 C++11 noexcept 之間的區別)

                • <tfoot id='xBEHz'></tfoot>

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

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

                        <tbody id='xBEHz'></tbody>

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

                          <i id='xBEHz'><tr id='xBEHz'><dt id='xBEHz'><q id='xBEHz'><span id='xBEHz'><b id='xBEHz'><form id='xBEHz'><ins id='xBEHz'></ins><ul id='xBEHz'></ul><sub id='xBEHz'></sub></form><legend id='xBEHz'></legend><bdo id='xBEHz'><pre id='xBEHz'><center id='xBEHz'></center></pre></bdo></b><th id='xBEHz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='xBEHz'><tfoot id='xBEHz'></tfoot><dl id='xBEHz'><fieldset id='xBEHz'></fieldset></dl></div>
                        1. 主站蜘蛛池模板: 日韩三级免费观看 | 日本精品一区二区三区在线观看 | 亚洲福利网 | 在线观看国产视频 | 日韩精品一区二区三区四区视频 | 亚洲欧美日韩中文字幕一区二区三区 | 一级片在线观看视频 | 久久久99国产精品免费 | 4h影视 | 精品一区欧美 | 精品国偷自产在线 | 久久精品国产99国产精品 | 色婷婷av久久久久久久 | 亚洲一区二区三区视频免费观看 | 天天澡天天狠天天天做 | 日韩精品视频一区二区三区 | 国产视频一区在线观看 | 国产久| 久草www | 99re6在线视频精品免费 | 奇米超碰在线 | 国产高清在线精品一区二区三区 | 九一在线| 亚洲成人精选 | 天堂综合网 | 亚洲精品一区二三区不卡 | 一区精品在线观看 | 中文字幕亚洲区一区二 | 欧美精品久久久 | 国产黄色av网站 | 91人人看 | 国产99视频精品免视看9 | 99久久精品免费看国产免费软件 | 欧美多人在线 | 亚洲欧洲精品成人久久奇米网 | 浴室洗澡偷拍一区二区 | 国产精品一区二区av | 日韩精品在线观看视频 | 色婷婷亚洲国产女人的天堂 | 日韩成人免费 | 91精品国产乱码久久久久久久久 |