#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++基本数据类型及其取值范围的更多相关文章

  1. mysql中数据类型的取值范围

    mysql整型bigint.int.mediumint.smallint 和 tinyint的语法介绍,如下: 1.bigint 从 -2^63 (-9223372036854775808) 到 2^ ...

  2. C语言中数据类型的取值范围

    C语言中数据类型的取值范围如下:char -128 ~ +127 (1 Byte)short -32767 ~ + 32768 (2 Bytes)unsigned short 0 ~ 65536 (2 ...

  3. 了解Java基本数据类型的取值范围

    拿byte类型做栗子 一个字节是8位二进制数,然后最高位会用来作为符号位.正数计算机是存的原码,负数是存的补码. 也就说byte正数最大是0111 1111,转化为十进制是:127(这就是byte的上 ...

  4. C语言中各个数据类型的取值范围

    因为CPU的差异,各系统中的数据类型所占的字节数(bytes)不同,二进制位数(bit)也不同.那么怎样才能知道自己系统的数据类型的字节数,位数呢? 授之以鱼不如授之以渔,大家可以自己从电脑里获取这些 ...

  5. Java基本数据类型的取值范围

    版权声明:本文为博主原创文章,未经博主允许不得转载. 先看一段代码public class Hello{    public static void main(String[] args){      ...

  6. Java基础:8种基本数据类型,取值范围和储存字节说明。

    Java中,一共有8种基本数据类型: 4种整数型:int,short,long,byte. 2种浮点型:float,double. 1种字符类型:char. 1种表示真值的类型:boolean. [S ...

  7. java数据类型,取值范围,引用类型解析

      与javascript不同,Java是强类型语言,在定义变量前需要声明数据类型.主要分两种数据类型:基本数据类型和引用数据类型. 1.基本数据类型分析: 基本数据类型 数值型 整数型 byte字节 ...

  8. java 基本数据类型的取值

    一. 1.基本类型:short 二进制位数:16 包装类:java.lang.Short 最小值:Short.MIN_VALUE=-32768 (-2的15此方)最大值:Short.MAX_VALUE ...

  9. Java 基本数据类型的取值范围

    基本数据类型,字节数,位数,最大值和最小值. 1. 基本类型:short 二进制位数:16 包装类:java.lang.Short 最小值:Short.MIN_VALUE=-32768 (-2的15此 ...

随机推荐

  1. Confluence 6 数据导入和导出

    Confluence 管理员和用户可以从各种方法向  Confluence 中导入数据.针对不同的导入方式,有关权限的要求也是不相同的.请参考页面 Import Content Into Conflu ...

  2. numpy:dot与multiply

    http://blog.csdn.net/iamzhangzhuping/article/details/52370241

  3. Java的实验程序之输出单个文件中的前 N 个最常出现的英语单词

    日期:2018.10.11 星期四 博客期:016 题目:输出单个文件中的前 N 个最常出现的英语单词,并输出到文本文件中 在程序运行之前,我试着先写了字符的字母的总结,加载代码如下: //如下是第一 ...

  4. AngularJs中,如何在ng-repeat完成之后,执行Js脚本

    //ng-repeat生成4个li,生成后再执行自定义方法fn在每个li后加一根横线 <script> var myapp=angular.module('myapp',[]); myap ...

  5. dubbo源码之Directory与LoadBalance

    Directory: 集群目录服务Directory, 代表多个Invoker, 可以看成List<Invoker>,它的值可能是动态变化的比如注册中心推送变更.集群选择调用服务时通过目录 ...

  6. list的add()方法与addAll()方法简介

    简单描述:月读别人的代码,发现了一个有意思的东西,list的一个方法,addAll(),然后就去度娘了一下,发现这个还挺有用的. 吐槽一下:为什么自己没发现这个方法呢?因为平时自己写list的时候,基 ...

  7. trade war

    问题 C: trade war 时间限制: 1 Sec  内存限制: 128 MB 题目描述 2018年的春天,特朗普这个不靠谱的的家伙悍然向中国发起了贸易战,贸易战是一场没有赢家的战争,美国向中国商 ...

  8. mac 显示/不显示"任何来源"_ mac打开安装文件显示文件破损解决办法

    系统: macOS_10.12 导致文件破损原因: 软件有经过了汉化或者破解,所以可能被Mac认为「已损坏」 解决问题办法: 系统偏好设置 -> 安全性与隐私 -> 通用 -> 选择 ...

  9. Selenium+PhantomJS使用时报错原因及解决方案

    问题 今天在使用selenium+PhantomJS动态抓取网页时,出现如下报错信息: UserWarning: Selenium support for PhantomJS has been dep ...

  10. (转)HTTPS到底是个啥玩意儿?

    详细见:https://blog.csdn.net/zgwangbo/article/details/50889623 ,建立交互的过程见下图: