c++各种数据类型表示范围
符号属性 长度属性 基本型 所占位数 取值范围 输入符举例 输出符举例
-- -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%u
signed -- char 8 -2^7 ~ 2^7-1 %c %c、%d、%u
unsigned -- char 8 0 ~ 2^8-1 %c %c、%d、%u
[signed] short [int] 16 -2^15 ~ 2^15-1 %hd
unsigned short [int] 16 0 ~ 2^16-1 %hu、%ho、%hx
[signed] -- int 32 -2^31 ~ 2^31-1 %d
unsigned -- [int] 32 0 ~ 2^32-1 %u、%o、%x
[signed] long [int] 32 -2^31 ~ 2^31-1 %ld
unsigned long [int] 32 0 ~ 2^32-1 %lu、%lo、%lx
[signed] long long [int] 64 -2^63 ~ 2^63-1 %I64d
unsigned long long [int] 64 0 ~ 2^64-1 %I64u、%I64o、%I64x
-- -- float 32 +/- 3.40282e+038 %f、%e、%g
-- -- double 64 +/- 1.79769e+308 %lf、%le、%lg %f、%e、%g
-- long double 96 +/- 1.79769e+308 %Lf、%Le、%Lg
#include<iostream>
#include <limits>
using namespace std;int main()
{//boolcout << "bool: \t\t" << "所占字节数:" << sizeof(bool);cout << "\t最大值:" << (numeric_limits<bool>::max)();cout << "\t\t最小值:" << (numeric_limits<bool>::min)() << endl;//charcout << "char: \t\t" << "所占字节数:" << sizeof(char);cout << "\t最大值:" << (numeric_limits<char>::max)();cout << "\t\t最小值:" << (numeric_limits<char>::min)() << endl;//signed charcout << "signed char: \t" << "所占字节数:" << sizeof(signed char);cout << "\t最大值:" << (numeric_limits<signed char>::max)();cout << "\t\t最小值:" << (numeric_limits<signed char>::min)() << endl;//unsigned charcout << "unsigned char: \t" << "所占字节数:" << sizeof(unsigned char);cout << "\t最大值:" << (numeric_limits<unsigned char>::max)();cout << "\t\t最小值:" << (numeric_limits<unsigned char>::min)() << endl;//wchar_tcout << "wchar_t: \t" << "所占字节数:" << sizeof(wchar_t);cout << "\t最大值:" << (numeric_limits<wchar_t>::max)();cout << "\t\t最小值:" << (numeric_limits<wchar_t>::min)() << endl;//shortcout << "short: \t\t" << "所占字节数:" << sizeof(short);cout << "\t最大值:" << (numeric_limits<short>::max)();cout << "\t\t最小值:" << (numeric_limits<short>::min)() << endl;//intcout << "int: \t\t" << "所占字节数:" << sizeof(int);cout << "\t最大值:" << (numeric_limits<int>::max)();cout << "\t最小值:" << (numeric_limits<int>::min)() << endl;//unsignedcout << "unsigned: \t" << "所占字节数:" << sizeof(unsigned);cout << "\t最大值:" << (numeric_limits<unsigned>::max)();cout << "\t最小值:" << (numeric_limits<unsigned>::min)() << endl;//longcout << "long: \t\t" << "所占字节数:" << sizeof(long);cout << "\t最大值:" << (numeric_limits<long>::max)();cout << "\t最小值:" << (numeric_limits<long>::min)() << endl;//unsigned longcout << "unsigned long: \t" << "所占字节数:" << sizeof(unsigned long);cout << "\t最大值:" << (numeric_limits<unsigned long>::max)();cout << "\t最小值:" << (numeric_limits<unsigned long>::min)() << endl;//floatcout << "float: \t\t" << "所占字节数:" << sizeof(float);cout << "\t最大值:" << (numeric_limits<float>::max)();cout << "\t最小值:" << (numeric_limits<float>::min)() << endl;//size_tcout << "size_t: \t" << "所占字节数:" << sizeof(size_t);cout << "\t最大值:" << (numeric_limits<size_t>::max)();cout << "\t最小值:" << (numeric_limits<size_t>::min)() << endl;//doublecout << "double: \t" << "所占字节数:" << sizeof(double);cout << "\t最大值:" << (numeric_limits<double>::max)();cout << "\t最小值:" << (numeric_limits<double>::min)() << endl;//long longcout << "long long: \t" << "所占字节数:" << sizeof(long long);cout << "\t最大值:" << (numeric_limits<long long>::max)();cout << "\t最小值:" << (numeric_limits<long long>::min)() << endl;//long doublecout << "long double: \t" << "所占字节数:" << sizeof(long double);cout << "\t最大值:" << (numeric_limits<long double>::max)();cout << "\t最小值:" << (numeric_limits<long double>::min)() << endl;return 0;
}
转载于:https://www.cnblogs.com/hdk1993/p/4371704.html
c++各种数据类型表示范围相关推荐
- Postman使用Date数据类型,Postman发送Date类型数据,Postman模拟前端调用
Postman使用Date数据类型: 在form-data数据类型下,使用 2021/7/7 11:11:00 (yyyy/MM/dd HH:mm:ss) 的数据格式即可 如下: 在json数据格式中 ...
- 大数据中用到的新的数据类型bigint、decimal、smallint、tinyint
在对比oracle数据库和大数据库的时候,发现了几个用以存放数字的新的类型bigint.decimal.smallint.tinyint,为了对比之间的不同,我进行了统计 bigint 可以精确的表示 ...
- NumPy — 创建全零、全1、空、arange 数组,array 对象类型,astype 转换数据类型,数组和标量以及数组之间的运算,NumPy 数组共享内存
NumPy 简介 一个用 python 实现的科学计算包.包括: 1.一个强大的 N 维数组对象 Array : 2.比较成熟的(广播)函数库: 3.用于整合 C/C++ 和 Fortran 代码的工 ...
- 【JavaScript总结】JavaScript语法基础:数据类型
------>数据类型有哪些? ->基本类型:数字类型,布尔类型,字符串类型 ->引用类型:对象类型,函数类型 ->空类型:null 和 undefined ->运算符: ...
- 数据类型对应的字节数
20210622 https://www.icode9.com/content-4-421680.html 32位和64位常用数据结构所占字节数 20210126 1 2 4 8 1248 刚好都是2 ...
- tensorflow2.0 基础一 常用数据类型及转换
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/weixin_43619065/arti ...
- 深入浅出Redis五种基本数据类型
文章目录 1.String SDS(Simple Dynamic String) 2.RedisDB设计 3.List 4.Hash 5.Set intset 6.ZSet skiplist 1.St ...
- TVM自定义数据类型
TVM自定义数据类型 本文将介绍"自定义数据类型"框架,该框架可在TVM中使用自定义数据类型. 介绍 在设计加速器时,关键是如何近似地表示硬件中的实数.这个问题具有长期的行业标准解 ...
- 自主数据类型:在TVM中启用自定义数据类型探索
自主数据类型:在TVM中启用自定义数据类型探索 介绍 在设计加速器时,一个重要的决定是如何在硬件中近似地表示实数.这个问题有一个长期的行业标准解决方案:IEEE 754浮点标准.1.然而,当试图通过构 ...
- 基本数据类型转换规则
基本数据类型转换规则 前言 一. byte.short.char运算的规则 二. 多种数据类型混合运算规则 三.总结 前言 在这篇文章中,我对Java的基本类型数据类型的混合运算做了一些总结,希望可以 ...
最新文章
- 剑指offer 重建二叉树
- 线性代数一之矩阵转向量随机化求解——神奇的矩阵(BZOJ)+向量内积
- 机器学习:空间变换进行非线性分类
- 以太坊创世区块源码分析
- 逃离泄露事件,阿里云安全默认防御大揭秘 | 问底中国 IT 技术演进
- 20145202 《信息安全系统设计基础》第6周学习总结(2)
- Mysql自动设置时间(自动获取时间,填充时间)
- tensorflow: deep_dream代码及原理分析
- java用户邮件激活
- python推荐系统算法朴素贝叶斯_Java实现的朴素贝叶斯算法示例
- natapp反向代理
- Chrome 75 lazy-loading
- 深入浅出理解数据库s锁和x锁
- 帝国时代3如何快速实现增加主城生命值
- android 耗时分析,启动耗时分析(四)-具体方法耗时分析
- 买股票也要会买跌,股票不是只有涨的时候才能买的
- 小红书用户画像分析_用户画像分析会成为第一品牌竞争力吗?
- 一、代理模式{proxy-pattern}
- c语言实现补码转换成原码,(转)C语言之原码、反码和补码(示例代码)
- OSTA考试认证详细介绍之计算机
热门文章
- Linus采访对Linux对git和对代码品味的理解
- 不同版本浏览器前端标准兼容性对照表以及CORS解决跨域和CSRF安全问题解决方案
- ASP.NET的(HttpModule,HttpHandler)
- Spring源码分析【2】-Tomcat和Sping的连接点
- 指针的本质--u_char*指针在Nginx源码中的应用及原因
- C++/C++11中std::runtime_error的使用
- 二维码Aztec简介及其解码实现(zxing-cpp)
- docker mysql 生产环境_Docker构建MySQL环境
- java fork join原理_细说Fork/Join框架
- 三菱plc232数据线驱动下载_三菱PLC与西门子PLC有什么区别?