博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++各种数据类型表示范围
阅读量:6503 次
发布时间:2019-06-24

本文共 3372 字,大约阅读时间需要 11 分钟。

 

符号属性     长度属性     基本型     所占位数     取值范围       输入符举例      输出符举例

--            --          char         8         -2^7 ~ 2^7-1        %c          %c、%d、%u

signed        --          char         8         -2^7 ~ 2^7-1        %c          %c、%d、%u
unsigned      --          char         8         0 ~ 2^8-1           %c          %c、%d、%u

[signed]      short       [int]        16        -2^15 ~ 2^15-1              %hd

unsigned      short       [int]        16        0 ~ 2^16-1             %hu、%ho、%hx

[signed]      --           int         32        -2^31 ~ 2^31-1              %d

unsigned      --          [int]        32        0 ~ 2^32-1              %u、%o、%x

[signed]      long        [int]        32        -2^31 ~ 2^31-1              %ld

unsigned      long        [int]        32        0 ~ 2^32-1             %lu、%lo、%lx

[signed]      long long   [int]        64        -2^63 ~ 2^63-1             %I64d

unsigned      long long   [int]        64        0 ~ 2^64-1          %I64u、%I64o、%I64x

--            --          float        32       +/- 3.40282e+038         %f、%e、%g

--            --          double       64       +/- 1.79769e+308 %lf、%le、%lg   %f、%e、%g
--            long        double       96       +/- 1.79769e+308        %Lf、%Le、%Lg

#include
#include
using namespace std;int main(){ //bool cout << "bool: \t\t" << "所占字节数:" << sizeof(bool); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t\t最小值:" << (numeric_limits
::min)() << endl; //char cout << "char: \t\t" << "所占字节数:" << sizeof(char); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t\t最小值:" << (numeric_limits
::min)() << endl; //signed char cout << "signed char: \t" << "所占字节数:" << sizeof(signed char); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t\t最小值:" << (numeric_limits
::min)() << endl; //unsigned char cout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t\t最小值:" << (numeric_limits
::min)() << endl; //wchar_t cout << "wchar_t: \t" << "所占字节数:" << sizeof(wchar_t); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t\t最小值:" << (numeric_limits
::min)() << endl; //short cout << "short: \t\t" << "所占字节数:" << sizeof(short); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t\t最小值:" << (numeric_limits
::min)() << endl; //int cout << "int: \t\t" << "所占字节数:" << sizeof(int); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //unsigned cout << "unsigned: \t" << "所占字节数:" << sizeof(unsigned); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //long cout << "long: \t\t" << "所占字节数:" << sizeof(long); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //unsigned long cout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //float cout << "float: \t\t" << "所占字节数:" << sizeof(float); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //size_t cout << "size_t: \t" << "所占字节数:" << sizeof(size_t); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //double cout << "double: \t" << "所占字节数:" << sizeof(double); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //long long cout << "long long: \t" << "所占字节数:" << sizeof(long long); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; //long double cout << "long double: \t" << "所占字节数:" << sizeof(long double); cout << "\t最大值:" << (numeric_limits
::max)(); cout << "\t最小值:" << (numeric_limits
::min)() << endl; return 0;}

转载于:https://www.cnblogs.com/hdk1993/p/4371704.html

你可能感兴趣的文章
prototype
查看>>
Android学习路线
查看>>
Linux下的redis的持久化,主从同步及哨兵
查看>>
在相同的主机上创建一个duplicate数据库
查看>>
Date15
查看>>
从Date类型转为中文字符串
查看>>
基于multisim的fm调制解调_苹果开始自研蜂窝网调制解调器 最快2024年能用上?
查看>>
mupdf不支持x64_Window权限维持(七):安全支持提供者
查看>>
cf修改游戏客户端是什么意思_瓦罗兰特很有可能取代cf成为国内最火的fps游戏...
查看>>
proto文件支持继承吗_JavaScript继承(一)——原型链
查看>>
labview如何弹出提示窗口_LabVIEW开发者必读的问答汇总,搞定疑难杂症全靠它了!...
查看>>
提取series中的数值_Python中None和numpy.nan的区别
查看>>
hikariconfig mysql_HikariConfig配置解析
查看>>
mysql批量数据多次查询数据库_mysql数据库批量操作
查看>>
jquery 乱码 传参_jquery获取URL中参数解决中文乱码问题的两种方法
查看>>
JDBC_MySQL_jdbc连接mysql_MySQL
查看>>
mysql cte的好处_Mysql 8 重要新特性 - CTE 通用表表达式
查看>>
zcu106 固化_xilinx zcu106 vcu demo
查看>>
java ftpclient 代码_java后台代码ftpclient下载文件
查看>>
java数据库生成model_继承BaseModelGenerator 生成Model时添加数据库表字段 生成代码示例...
查看>>