欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
C/C++中各種類(lèi)型int、long、double、char表示范圍(最大最小值)
http://blog.csdn.net/xuexiacm/article/details/8122267
2012

  1. #include<iostream>  
  2. #include<string>  
  3. #include <limits>  
  4. using namespace std;  
  5.   
  6. int main()  
  7. {  
  8.     cout << "type: \t\t" << "************size**************"<< endl;  
  9.     cout << "bool: \t\t" << "所占字節數:" << sizeof(bool);  
  10.     cout << "\t最大值:" << (numeric_limits<bool>::max)();  
  11.     cout << "\t\t最小值:" << (numeric_limits<bool>::min)() << endl;  
  12.     cout << "char: \t\t" << "所占字節數:" << sizeof(char);  
  13.     cout << "\t最大值:" << (numeric_limits<char>::max)();  
  14.     cout << "\t\t最小值:" << (numeric_limits<char>::min)() << endl;  
  15.     cout << "signed char: \t" << "所占字節數:" << sizeof(signed char);  
  16.     cout << "\t最大值:" << (numeric_limits<signed char>::max)();  
  17.     cout << "\t\t最小值:" << (numeric_limits<signed char>::min)() << endl;  
  18.     cout << "unsigned char: \t" << "所占字節數:" << sizeof(unsigned char);  
  19.     cout << "\t最大值:" << (numeric_limits<unsigned char>::max)();  
  20.     cout << "\t\t最小值:" << (numeric_limits<unsigned char>::min)() << endl;  
  21.     cout << "wchar_t: \t" << "所占字節數:" << sizeof(wchar_t);  
  22.     cout << "\t最大值:" << (numeric_limits<wchar_t>::max)();  
  23.     cout << "\t\t最小值:" << (numeric_limits<wchar_t>::min)() << endl;  
  24.     cout << "short: \t\t" << "所占字節數:" << sizeof(short);  
  25.     cout << "\t最大值:" << (numeric_limits<short>::max)();  
  26.     cout << "\t\t最小值:" << (numeric_limits<short>::min)() << endl;  
  27.     cout << "int: \t\t" << "所占字節數:" << sizeof(int);  
  28.     cout << "\t最大值:" << (numeric_limits<int>::max)();  
  29.     cout << "\t最小值:" << (numeric_limits<int>::min)() << endl;  
  30.     cout << "unsigned: \t" << "所占字節數:" << sizeof(unsigned);  
  31.     cout << "\t最大值:" << (numeric_limits<unsigned>::max)();  
  32.     cout << "\t最小值:" << (numeric_limits<unsigned>::min)() << endl;  
  33.     cout << "long: \t\t" << "所占字節數:" << sizeof(long);  
  34.     cout << "\t最大值:" << (numeric_limits<long>::max)();  
  35.     cout << "\t最小值:" << (numeric_limits<long>::min)() << endl;  
  36.     cout << "unsigned long: \t" << "所占字節數:" << sizeof(unsigned long);  
  37.     cout << "\t最大值:" << (numeric_limits<unsigned long>::max)();  
  38.     cout << "\t最小值:" << (numeric_limits<unsigned long>::min)() << endl;  
  39.     cout << "double: \t" << "所占字節數:" << sizeof(double);  
  40.     cout << "\t最大值:" << (numeric_limits<double>::max)();  
  41.     cout << "\t最小值:" << (numeric_limits<double>::min)() << endl;  
  42.     cout << "long double: \t" << "所占字節數:" << sizeof(long double);  
  43.     cout << "\t最大值:" << (numeric_limits<long double>::max)();  
  44.     cout << "\t最小值:" << (numeric_limits<long double>::min)() << endl;  
  45.     cout << "float: \t\t" << "所占字節數:" << sizeof(float);  
  46.     cout << "\t最大值:" << (numeric_limits<float>::max)();  
  47.     cout << "\t最小值:" << (numeric_limits<float>::min)() << endl;  
  48.     cout << "size_t: \t" << "所占字節數:" << sizeof(size_t);  
  49.     cout << "\t最大值:" << (numeric_limits<size_t>::max)();  
  50.     cout << "\t最小值:" << (numeric_limits<size_t>::min)() << endl;  
  51.     cout << "string: \t" << "所占字節數:" << sizeof(string) << endl;  
  52.     // << "\t最大值:" << (numeric_limits<string>::max)() << "\t最小值:" << (numeric_limits<string>::min)() << endl;  
  53.     cout << "type: \t\t" << "************size**************"<< endl;  
  54.     return 0;  
  55. }  



/*運行結果分析:

以上結果已經(jīng)很明白了,一下補充說(shuō)明幾點(diǎn):

概念、整型:表示整數、字符和布爾值的算術(shù)類(lèi)型合稱(chēng)為整型(integral type)。

關(guān)于帶符號與無(wú)符號類(lèi)型:整型 int、stort  和  long 都默認為帶符號型。要獲得無(wú)符號型則必須制定該類(lèi)型為unsigned,比如unsigned long。unsigned int類(lèi)型可以簡(jiǎn)寫(xiě)為unsigned,也就是說(shuō),unsigned后不加其他類(lèi)型說(shuō)明符就意味著(zhù)是unsigned int。

一字節表示八位,即:1byte = 8 bit;

int: 4byte =  32 bit 有符號signed范圍:2^31-1 ~ -2^31即:2147483647 ~ -2147483648無(wú)符號unsigned范圍:2^32-1 ~ 0即:4294967295 ~ 0

long: 4 byte = 32 bit 同int型

double: 8 byte = 64 bit 范圍:1.79769e+308 ~ 2.22507e-308

long double: 12 byte = 96 bit 范圍: 1.18973e+4932 ~ 3.3621e-4932

float: 4 byte = 32 bit 范圍: 3.40282e+038 ~ 1.17549e-038

int、unsigned、long、unsigned long 、double的數量級最大都只能表示為10億,即它們表示十進(jìn)制的位數不超過(guò)10個(gè),即可以保存所有9位整數。而short只是能表示5位;


另外對于浮點(diǎn)說(shuō)而言:使用double類(lèi)型基本上不會(huì )有錯。在float類(lèi)型中隱式的精度損失是不能忽視的,二雙精度計算的代價(jià)相對于單精度可以忽略。事實(shí)上,在有些機器上,double類(lèi)型比f(wàn)loat類(lèi)型的計算要快得多。float型只能保證6位有效數字,而double型至少可以保證15位有效數字(小數點(diǎn)后的數位),long double型提供的精度通常沒(méi)有必要,而且還要承擔額外的運行代價(jià)。

double是8字節共64位,其中小數位占52位,2-^52=2.2204460492503130808472633361816e-16,量級為10^-16,故能夠保證2^-15的所有精度。

在有些機器上,用long類(lèi)型進(jìn)行計算所付出的運行時(shí)代價(jià)遠遠高于用int類(lèi)型進(jìn)行同樣計算的代價(jià),所以算則類(lèi)型前要先了解程序的細節并且比較long類(lèi)型與int類(lèi)型的實(shí)際運行時(shí)性能代價(jià)。



歡迎提出寶貴意見(jiàn),以幫助我改進(jìn),不勝感激?。?!

——桑海整理

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
數據類(lèi)型的最大最小值
關(guān)于numeric_limits
178 f0603
測試VC對空虛基類(lèi)的處理及內存對齊
全面整理的C++面試題 - ljzcome的專(zhuān)欄
unsigned char 與 char
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久