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

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

C++中数据类型的取值,范围,我们使用到了 limits这个类

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

转载于:https://www.cnblogs.com/hiwoshixiaoyu/p/10035096.html

你可能感兴趣的文章
Csharp:Windowsform using CheckedListBox Datasource
查看>>
android 直接在屏幕上绘图
查看>>
[网络流24题] 方格取数问题/骑士共存问题 (最大流->最大权闭合图)
查看>>
PHP中curl模拟post上传及接收文件
查看>>
qt creator中添加自定义的类后需要执行qmake
查看>>
Openstack+Kubernetes+Docker微服务实践之路--选型
查看>>
操作系统学习---进程管理(二)
查看>>
如何简单形象又有趣地讲解神经网络是什么?知乎
查看>>
MVVM
查看>>
Sql 查询当天、本周、本月记录
查看>>
console.log的一个应用 -----用new方法生成一个img对象和document.createElement方法创建一个img对象的区别...
查看>>
哈希槽
查看>>
AndHand库辅助库
查看>>
plink命令
查看>>
python进阶—OpenCV之常用图像操作函数说明(转)
查看>>
幻灯片会场管理
查看>>
.NET Remoting 体系结构 之 生命周期管理
查看>>
ReactiveCocoa基本组件:理解和使用RACCommand
查看>>
BZOJ 3992 【SDOI2015】 序列统计
查看>>
如何解决 yum安装出现This system is not registered with RHN
查看>>