#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. Walle,一个开源的web代码发布管理系统

    前言 Walle 一个web部署系统工具,可能也是个持续发布工具,配置简单.功能完善.界面流畅.开箱即用!支持git.svn版本管理,支持各种web代码发布,静态的HTML,动态PHP,需要编译的JA ...

  2. 1706: 神奇的编码(zzuli)

    题目描述 假如没有阿拉伯数字,我们要怎么表示数字呢 小明想了一个方法如下: 1 -> A 2 -> B 3 -> C .... 25 -> Y 26 -> Z 27 -& ...

  3. poj2116 模拟题

    不知道错在哪里 /* 给定两个斐波那契表示数,要求用标准化表达方式表达 然后将这两个数加起来,和也用标准化方式表达 思路:显然要将这两个数先用十进制表示,和也用十进制表示 然后在转化成二进制即可 1 ...

  4. Linux之man命令详解及中文汉化

    使用方法 Linux man中的man就是manual的缩写,用来查看系统中自带的各种参考手册 使用方法: man command 示例: [root@VM_0_13_centos ~]# man l ...

  5. Python os.walk() 方法遍历文件目录

    概述 os.walk() 方法用于通过在目录树中游走输出在目录中的文件名,向上或者向下. os.walk() 方法是一个简单易用的文件.目录遍历器,可以帮助我们高效的处理文件.目录方面的事情. 在Un ...

  6. 微信小程序--WXS---JS 代码插入

    主页要使用的JS代码放在index.js里面 例 Page({ data: { array: [1, 2, 3, 4, 5, 1, 2, 3, 4] } }) 只复制以下这段 data: { arra ...

  7. 牛客寒假算法基础集训营4 I题 Applese 的回文串

    链接:https://ac.nowcoder.com/acm/contest/330/I 来源:牛客网 自从 Applese 学会了字符串之后,精通各种字符串算法,比如--判断一个字符串是不是回文串. ...

  8. 如何设置Navicat的显示字体与字体大小?

    方法/步骤     打开Navicat   点击[工具]菜单,再选择[选项]   在[选项]界面,点击[外观]下的[字体]   设置网格字体和大小   设置编辑器字体和大小   设置命令列界面字体和大 ...

  9. python---使用字典来实现链接表图

    最后一章,坚持!!! # coding = utf-8 class Vertex: def __init__(self, key): self.id = key self.connected_to = ...

  10. tjoi2018

    1.[TJOI2018]数学计算 傻逼题 会发现符合线段树分治的特点 每个数的操作范围都是连续的 然后就等于区间修改了 #include <bits/stdc++.h> using nam ...