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此 ...
随机推荐
- FTP服务器配置和管理
一:ftp 简介 1:ftp服务: internet 是一个非常复杂额计算机环境,其中有pc/mac/小型机/大型机等.而在这些计算机上运行的操作系统也是五花八门,有 unix.Linux.微软的wi ...
- Java的家庭记账本程序(F)
日期:2019.2.17 博客期:034 星期日 我先配置了Android的相关环境,先试着做了Hello World的测试,但是却出现了很严重的问题,问题如下: Unable to get curr ...
- kali linux 更新问题
1.使用一次更新和升级软件替换 apt-get install && apt -y full -upgrade 之后使用 reboot重启 系统,重启之后 再次使用命令 ap ...
- this作用范围
1. this的指向 var name='window';var obj={ name:'obj', say:function(){ return function(){ return this.na ...
- 如何在地址栏(title标签里)和收藏夹里 加上网站的标志ICO、LOGO图片
第一步:首先你必须要制作一个看起来既清楚又容易辨识的.ico格式的小图片. 我们将图标的大小定义为16x16 像素.此外在制作图形文件的时候,你可能需要把色盘设定成只使用标准的 16 色 Window ...
- Python属性(@property)
创建用于计算机的属性 在Python中,可以通过@property(装饰器)将一个方法转换为属性,从而实现用于计算的属性.将方法转换为属性后,可以直接通过方法名来访问方法,而不需要再添加一对小括号&q ...
- ajax--参数默认值问题
注:通过参数默认值,能让参数映射更加灵活,有些参数可以不必传递,如果传递则 覆盖默认.并且永远都是后面的覆盖前面的内容 通过$.extend合并对象 语法1: var newobj= $.extend ...
- IDEA文件对比
- Sqoop使用,mysql,hbase,hive等相互转换
Sqoop 是一款用来在不同数据存储软件之间进行数据传输的开源软件,它支持多种类型的数据储存软件. 安装 Sqoop 1.下载sqoop并加mysql驱动包 http://mirror.bit.edu ...
- SqlServer2012清除日志文件
SqlServer在使用中会产生大量的日志文件,当不需要的时候可以进行删除. 删除方式: 右键数据库-->任务-->收缩-->文件 进入收缩文件页面,按照如下配置就可以了 有时候收缩 ...