国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
如何查看各個(gè)類型的最大值

http://blog.csdn.net/bichenggui/article/details/4488072

2009

問題源于同事的一個(gè)問題,VC編譯器里如何查看double的最大值? 他在limits.h里沒找到。

 

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

 

#include <iostream>

#include <limits>

 

using namespace std;

 

// compile with: /EHsc

 

 

int main(){

 

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

 

}

 

運(yùn)行平臺(tái)為VS2008,如果出現(xiàn)max編譯沖突,可以加上#undef max。

 

模板類numeric_limits的聲明是:

template <typename T>

numeric_limits<T>

 

// 變量和成員函數(shù)////    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()//////////////////////////////////////////////////////////////////////
實(shí)例代碼:
#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;}

 

請(qǐng)運(yùn)行相關(guān)的代碼查看結(jié)果。

 

 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
關(guān)于numeric_limits
C++ limits頭文件的用法(numeric
C++ limits頭文件的用法(numeric_limits)
數(shù)據(jù)類型的最大最小值
C++標(biāo)準(zhǔn)模板庫(kù)方法STL和函數(shù)使用說(shuō)明
讓Vulkan告訴你你的顯卡有多強(qiáng)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服