• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            S.l.e!ep.¢%

            像打了激速一樣,以四倍的速度運轉,開心的工作
            簡單、開放、平等的公司文化;尊重個性、自由與個人價值;
            posts - 1098, comments - 335, trackbacks - 0, articles - 1
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            如何查看各個類型的最大值

            Posted on 2010-01-18 12:12 S.l.e!ep.¢% 閱讀(539) 評論(0)  編輯 收藏 引用 所屬分類: C++

            ?如何查看各個類型的最大值 收藏
            問題源于同事的一個問題,VC編譯器里如何查看double的最大值? 他在limits.h里沒找到。

            在limits.h里面,只可以看到整型的最大值,但是看不到浮點數的最大值。浮點數的最大值可以這樣得到:

            #include <iostream>

            #include <limits>

            using namespace std;

            // compile with: /EHscint main(){

            ?? cout << numeric_limits<double>::max() << endl;?

            }

            運行平臺為VS2008,如果出現max編譯沖突,可以加上#undef max。

            模板類numeric_limits的聲明是:

            template <typename T>

            numeric_limits<T>

            // 變量和成員函數
            //
            //??? has_denorm
            //??? has_denorm_loss
            //??? has_infinity
            //??? has_quiet_NaN
            //??? has_signaling_NaN
            //??? is_bounded
            //??? is_exact
            //??? is_iec559
            //??? is_integer
            //??? is_modulo
            //??? is_signed
            //??? is_specialized
            //??? tinyness_before
            //??? traps
            //??? round_style
            //??? digits
            //??? digits10
            //??? max_exponent
            //??? max_exponent10
            //??? min_exponent
            //??? min_exponent10
            //??? radix;
            //??? denorm_min()
            //??? epsilon()
            //??? infinity()
            //??? max()
            //??? min()
            //??? quiet_ NaN()
            //??? round_error()
            //??? signaling_NaN()
            //////////////////////////////////////////////////////////////////////
            實例代碼:#include <iostream>
            #include <limits>

            using namespace std;

            int main() {
            ??? cout << " 1 The minimum value for char is " <<
            ??????? (int)numeric_limits<char>::min() << endl;
            ??? cout << " 2 The minimum value for int is? " <<
            ??????? numeric_limits<int>::min() << endl;
            ??? cout << " 3 The maximum value for char is " <<
            ??????? (int)numeric_limits<char>::max() << endl;
            ??? cout << " 4 The maximum value for int is? " <<
            ??????? numeric_limits<int>::max() << endl;
            ??? cout << " 5 The number of bits to represent a char is " <<
            ??????? numeric_limits<char>::digits << endl;
            ??? cout << " 6 The number of bits to represent an int is " <<
            ??????? numeric_limits<int>::digits << endl;
            ??? cout <<" 7 The number of digits representable in base 10 for float is "
            ???????? << numeric_limits<float>::digits10 << endl;
            ??? cout << " 8 Is a char signed?????????????? " <<
            ??????? numeric_limits<char>::is_signed << endl;
            ??? cout << " 9 Is an unsigned integer signed? " <<
            ??????? numeric_limits<unsigned int>::is_signed << endl;
            ??? cout << "10 Is an integer an integer? " <<
            ??????? numeric_limits<int>::is_integer << endl;
            ??? cout << "11 Is a float an integer??? " <<
            ??????? numeric_limits<float>::is_integer << endl;
            ??? cout << "12 Is an integer exact? " <<
            ??????? numeric_limits<int>::is_exact << endl;
            ??? cout << "13 Is a float exact?? " <<
            ??????? numeric_limits<float>::is_exact << endl;
            ??? cout << "14 The radix for float is??????????? "? <<
            ??????? numeric_limits<float>::radix << endl;
            ??? cout << "15 The epsilon for float is????????? " <<
            ??????? numeric_limits<float>::epsilon() << endl;
            ??? cout << "16 The round error for float is????? " <<
            ??????? numeric_limits<float>::round_error() << endl;
            ??? cout << "17 The minimum exponent for float is " <<
            ??????? numeric_limits<float>::min_exponent << endl;
            ??? cout << "18 The minimum exponent in base 10?? " <<
            ??????? numeric_limits<float>::min_exponent10 << endl;
            ??? cout << "19 The maximum exponent is?????????? " <<
            ??????? numeric_limits<float>::max_exponent << endl;
            ??? cout << "20 The maximum exponent in base 10?? " <<
            ??????? numeric_limits<float>::max_exponent10 << endl;
            ??? cout << "21 Can float represent positive infinity?? " <<
            ??????? numeric_limits<float>::has_infinity << endl;
            ??? cout << "22 Can double represent positive infinity? " <<
            ??????? numeric_limits<double>::has_infinity << endl;
            ??? cout << "23 Can int represent positive infinity? " <<
            ??????? numeric_limits<int>::has_infinity << endl;
            ??? cout << "24 Can float represent a NaN??????????? " <<
            ??????? numeric_limits<float>::has_quiet_NaN << endl;
            ??? cout << "25 Can float represent a signaling NaN? " <<
            ??????? numeric_limits<float>::has_signaling_NaN << endl;
            ??? cout << "26 Does float allow denormalized values??? " <<
            ??????? numeric_limits<float>::has_denorm << endl;
            ??? cout << "27 Does float detect denormalization loss? " <<
            ??????? numeric_limits<float>::has_denorm_loss << endl;
            ??? cout << "28 Representation of positive infinity for float " <<
            ??????? numeric_limits<float>::infinity() << endl;
            ??? cout << "29 Representation of quiet NaN for float???????? " <<
            ??????? numeric_limits<float>::quiet_NaN() << endl;
            ??? cout << "30 Minimum denormalized number for float???????? " <<
            ??????? numeric_limits<float>::denorm_min() << endl;
            ??? cout << "31 Minimum positive denormalized value for float " <<
            ??????? numeric_limits<float>::denorm_min() << endl;
            ??? cout << "32 Does float adhere to IEC 559 standard?? " <<
            ??????? numeric_limits<float>::is_iec559 << endl;
            ??? cout << "33 Is float bounded? " <<
            ??????? numeric_limits<float>::is_bounded << endl;
            ??? cout << "34 Is float modulo?? " <<
            ??????? numeric_limits<float>::is_modulo << endl;
            ??? cout << "35 Is int modulo???? " <<
            ??????? numeric_limits<float>::is_modulo << endl;
            ??? cout << "36 Is trapping implemented for float???? " <<
            ??????? numeric_limits<float>::traps << endl;
            ??? cout << "37 Is tinyness detected before rounding? " <<
            ??????? numeric_limits<float>::tinyness_before << endl;
            ??? cout << "38 What is the rounding style for float? " <<
            ??????? (int)numeric_limits<float>::round_style << endl;
            ??? cout << "39 What is the rounding style for int? " <<
            ??????? (int)numeric_limits<int>::round_style << endl;
            ??? cout << "40 How does a float represent a signaling NaN? " <<
            ??????? numeric_limits<float>::signaling_NaN() << endl;
            ??? cout << "41 Is int specialized? " <<
            ??????? numeric_limits<float>::is_specialized << endl;
            }請運行相關的代碼查看結果。


            本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/bichenggui/archive/2009/08/26/4488072.aspx

            久久99国产精品尤物| 性做久久久久久久久久久| 少妇精品久久久一区二区三区| 久久人人爽人人爽AV片| 久久免费看黄a级毛片| 久久国产精品成人影院| 久久久久国产精品人妻| 久久福利青草精品资源站免费| 久久午夜无码鲁丝片午夜精品| 狠狠色婷婷久久综合频道日韩| 好久久免费视频高清| 久久久噜噜噜久久中文字幕色伊伊 | 精品久久久一二三区| 久久国产精品成人影院| 国产精品久久久久久久人人看| 日本欧美久久久久免费播放网| 久久天天躁狠狠躁夜夜av浪潮 | 久久99精品国产一区二区三区| 亚洲国产成人久久笫一页| 97久久精品无码一区二区| 亚洲国产精品无码久久九九| 国产99久久精品一区二区| 一本久久a久久精品亚洲| 久久天天躁狠狠躁夜夜不卡| 国产精品成人99久久久久 | 久久国产精品99精品国产| 久久久久久免费视频| 国产精品免费久久| 久久免费精品一区二区| 色婷婷综合久久久久中文一区二区 | 久久精品国产精品亚洲精品| 久久精品无码一区二区日韩AV| 亚洲日本va午夜中文字幕久久| 国产精品久久久天天影视香蕉 | 久久久久亚洲爆乳少妇无| 国产成人久久777777| 久久精品国产一区二区三区日韩| 97超级碰碰碰久久久久| 久久免费国产精品一区二区| 国产精品99久久精品爆乳| 久久国产视屏|