c++基本数据类型及其取值范围
#include<iostream>
#include<string>
#include <limits>
using namespace std; int main()
{
cout << "type: \t\t\t" << "************size**************" << endl;
cout << "bool: \t\t\t" << "所占字节数:" << sizeof(bool);
cout << "\t\t最大值:" << (numeric_limits<bool>::max)();
cout << "\t\t\t\t\t\t\t最小值:" << (numeric_limits<bool>::min)() << endl; cout << "char: \t\t\t" << "所占字节数:" << sizeof(char);
cout << "\t\t最大值:" << (numeric_limits<char>::max)();
cout << "\t\t\t\t\t\t\t最小值:" << (numeric_limits<char>::min)() << endl; cout << "signed char: \t" << "所占字节数:" << sizeof(signed char);
cout << "\t\t最大值:" << (numeric_limits<signed char>::max)();
cout << "\t\t\t\t\t\t\t最小值:" << (numeric_limits<signed char>::min)() << endl; cout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char);
cout << "\t\t最大值:" << (numeric_limits<unsigned char>::max)();
cout << "\t\t\t\t\t\t\t最小值:" << (numeric_limits<unsigned char>::min)() << endl; cout << "wchar_t: \t\t" << "所占字节数:" << sizeof(wchar_t);
cout << "\t\t最大值:" << (numeric_limits<wchar_t>::max)();
cout << "\t\t\t\t最小值:" << (numeric_limits<wchar_t>::min)() << endl; cout << "short: \t\t\t" << "所占字节数:" << sizeof(short);
cout << "\t\t最大值:" << (numeric_limits<short>::max)();
cout << "\t\t\t\t\t\t最小值:" << (numeric_limits<short>::min)() << endl; cout << "int: \t\t\t" << "所占字节数:" << sizeof(int);
cout << "\t\t最大值:" << (numeric_limits<int>::max)();
cout << "\t\t\t\t最小值:" << (numeric_limits<int>::min)() << endl; cout << "unsigned: \t\t" << "所占字节数:" << sizeof(unsigned);
cout << "\t\t最大值:" << (numeric_limits<unsigned>::max)();
cout << "\t\t\t\t最小值:" << (numeric_limits<unsigned>::min)() << endl; cout << "long: \t\t\t" << "所占字节数:" << sizeof(long);
cout << "\t\t最大值:" << (numeric_limits<long>::max)();
cout << "\t\t最小值:" << (numeric_limits<long>::min)() << endl; cout << "long long: \t\t" << "所占字节数:" << sizeof(long long);
cout << "\t\t最大值:" << (numeric_limits<long long>::max)();
cout << "\t\t最小值:" << (numeric_limits<long long>::min)() << endl; cout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long);
cout << "\t\t最大值:" << (numeric_limits<unsigned long>::max)();
cout << "\t\t最小值:" << (numeric_limits<unsigned long>::min)() << endl; cout << "double: \t\t" << "所占字节数:" << sizeof(double);
cout << "\t\t最大值:" << (numeric_limits<double>::max)();
cout << "\t\t\t\t最小值:" << (numeric_limits<double>::min)() << endl; cout << "long double: \t" << "所占字节数:" << sizeof(long double);
cout << "\t最大值:" << (numeric_limits<long double>::max)();
cout << "\t\t\t\t最小值:" << (numeric_limits<long double>::min)() << endl; cout << "float: \t\t\t" << "所占字节数:" << sizeof(float);
cout << "\t\t最大值:" << (numeric_limits<float>::max)();
cout << "\t\t\t\t最小值:" << (numeric_limits<float>::min)() << endl; cout << "size_t: \t\t" << "所占字节数:" << sizeof(size_t);
cout << "\t\t最大值:" << (numeric_limits<size_t>::max)();
cout << "\t\t最小值:" << (numeric_limits<size_t>::min)() << endl; cout << "string: \t\t" << "所占字节数:" << sizeof(string) << endl;
// << "\t最大值:" << (numeric_limits<string>::max)() << "\t最小值:" << (numeric_limits<string>::min)() << endl;
cout << "\t\t\t\t" << "************size**************" << endl;
return ;
}
--- 参考自的博客kilen的博客。运行结果:
c++基本数据类型及其取值范围的更多相关文章
- mysql中数据类型的取值范围
mysql整型bigint.int.mediumint.smallint 和 tinyint的语法介绍,如下: 1.bigint 从 -2^63 (-9223372036854775808) 到 2^ ...
- C语言中数据类型的取值范围
C语言中数据类型的取值范围如下:char -128 ~ +127 (1 Byte)short -32767 ~ + 32768 (2 Bytes)unsigned short 0 ~ 65536 (2 ...
- 了解Java基本数据类型的取值范围
拿byte类型做栗子 一个字节是8位二进制数,然后最高位会用来作为符号位.正数计算机是存的原码,负数是存的补码. 也就说byte正数最大是0111 1111,转化为十进制是:127(这就是byte的上 ...
- C语言中各个数据类型的取值范围
因为CPU的差异,各系统中的数据类型所占的字节数(bytes)不同,二进制位数(bit)也不同.那么怎样才能知道自己系统的数据类型的字节数,位数呢? 授之以鱼不如授之以渔,大家可以自己从电脑里获取这些 ...
- Java基本数据类型的取值范围
版权声明:本文为博主原创文章,未经博主允许不得转载. 先看一段代码public class Hello{ public static void main(String[] args){ ...
- Java基础:8种基本数据类型,取值范围和储存字节说明。
Java中,一共有8种基本数据类型: 4种整数型:int,short,long,byte. 2种浮点型:float,double. 1种字符类型:char. 1种表示真值的类型:boolean. [S ...
- java数据类型,取值范围,引用类型解析
与javascript不同,Java是强类型语言,在定义变量前需要声明数据类型.主要分两种数据类型:基本数据类型和引用数据类型. 1.基本数据类型分析: 基本数据类型 数值型 整数型 byte字节 ...
- java 基本数据类型的取值
一. 1.基本类型:short 二进制位数:16 包装类:java.lang.Short 最小值:Short.MIN_VALUE=-32768 (-2的15此方)最大值:Short.MAX_VALUE ...
- Java 基本数据类型的取值范围
基本数据类型,字节数,位数,最大值和最小值. 1. 基本类型:short 二进制位数:16 包装类:java.lang.Short 最小值:Short.MIN_VALUE=-32768 (-2的15此 ...
随机推荐
- CF508E
贪心题是很有趣的... 首先,本题为括号匹配问题,那么可以考虑进行栈模拟 然后,我们思考一下如何匹配:虽然题目中仅对右括号的位置提出了区域性要求,但可以发现,对能匹配上的栈顶括号立刻进行匹配一定是一种 ...
- 滴水穿石-07Java开发中常见的错误
1:使用工具Eclipse 1.1 "语法错误" 仅当源级别为 1.5 时已参数化的类型才可用 设置eclipse,窗口—>java—>编译器—>JDK一致性调到 ...
- 插件使用一树形插件---zTree一zTree异步加载
zTree 可以实现异步加载.异步加载可以让初次加载速度快,带来好的用户体验. 异步加载 官方源码中的demo提示了例子.例子是采用php语言. 在java语言中,zTree如何与Servlet结合呢 ...
- k-近邻算法-优化约会网站的配对效果
KNN原理 1. 假设有一个带有标签的样本数据集(训练样本集),其中包含每条数据与所属分类的对应关系. 2. 输入没有标签的新数据后,将新数据的每个特征与样本集中数据对应的特征进行比较. a. 计算新 ...
- 20165323 实验三 敏捷开发与XP实践
一.实验报告封面 课程:Java程序设计 班级:1653班 姓名:杨金川 学号:20165323 指导教师:娄嘉鹏 实验日期:2018年4月28日 实验时间:13:45 - 15:25 实验序号:实验 ...
- ubuntu16.04安装skype
ubuntu16.04安装skype 一句命令搞定 wget https://repo.skype.com/latest/skypeforlinux-64.deb && sudo dp ...
- CAS统一登录认证好文汇集贴
悟空的专栏 https://blog.csdn.net/u010475041/article/category/7156505 LinBSoft的专栏 https://blog.csdn.net/ol ...
- WPF 下两种图片合成或加水印的方式(转载)
来源:http://www.cnblogs.com/lxblog/ 最近项目中应用多次应用了图片合成,为了今后方便特此记下. 在WPF下有两种图片合成的方式,一种还是用原来C#提供的GDI+方式,命名 ...
- python--自己实现的单链表常用功能
最近一个月,就耗在这上面吧. 很有收获的. # coding = utf-8 # 单向链表 class Node: def __init__(self, new_data): self.data = ...
- 使用shell脚本定时采集日志数据到hdfs分布式文件系统
1.首先对linux操作系统的crontab命令进行熟悉和了解: .crond是linux下用来周期性的执行某种任务或等待处理某些事件的一个守护进程,与windows下的计划任务类似,当安装完成操作系 ...