• C++中各种基本数据类型大小一览


      10^9以下用int10^18以下用long long

      C++代码如下

    #include<iostream>
    #include<string>
    #include <limits>
    using namespace std;
    
    int main()
    {
        cout << "type: 			" << "************size**************" << endl;
        cout << "bool: 			" << "numOfBytes:" << sizeof(bool);
        cout << "		maxValue:" << (numeric_limits<bool>::max)();
        cout << "				minValue:" << (numeric_limits<bool>::min)() << endl;
    
        cout << "char: 			" << "numOfBytes:" << sizeof(char);
        cout << "		maxValue:" << (numeric_limits<char>::max)();
        cout << "				minValue:" << (numeric_limits<char>::min)() << endl;
    
        cout << "signed char: 		" << "numOfBytes:" << sizeof(signed char);
        cout << "		maxValue:" << (numeric_limits<signed char>::max)();
        cout << "				minValue:" << (numeric_limits<signed char>::min)() << endl;
    
        cout << "unsigned char: 		" << "numOfBytes:" << sizeof(unsigned char);
        cout << "		maxValue:" << (numeric_limits<unsigned char>::max)();
        cout << "				minValue:" << (numeric_limits<unsigned char>::min)() << endl;
    
        cout << "wchar_t: 		" << "numOfBytes:" << sizeof(wchar_t);
        cout << "		maxValue:" << (numeric_limits<wchar_t>::max)();
        cout << "				minValue:" << (numeric_limits<wchar_t>::min)() << endl;
    
        cout << "short: 			" << "numOfBytes:" << sizeof(short);
        cout << "		maxValue:" << (numeric_limits<short>::max)();
        cout << "				minValue:" << (numeric_limits<short>::min)() << endl;
    
        cout << "int: 			" << "numOfBytes:" << sizeof(int);
        cout << "		maxValue:" << (numeric_limits<int>::max)();
        cout << "			minValue:" << (numeric_limits<int>::min)() << endl;
    
        cout << "unsigned: 		" << "numOfBytes:" << sizeof(unsigned);
        cout << "		maxValue:" << (numeric_limits<unsigned>::max)();
        cout << "			minValue:" << (numeric_limits<unsigned>::min)() << endl;
    
        cout << "long: 			" << "numOfBytes:" << sizeof(long);
        cout << "		maxValue:" << (numeric_limits<long>::max)();
        cout << "			minValue:" << (numeric_limits<long>::min)() << endl;
    
        cout << "long long: 		" << "numOfBytes:" << sizeof(long long);
        cout << "		maxValue:" << (numeric_limits<long long>::max)();
        cout << "		minValue:" << (numeric_limits<long long>::min)() << endl;
    
        cout << "unsigned long: 		" << "numOfBytes:" << sizeof(unsigned long);
        cout << "		maxValue:" << (numeric_limits<unsigned long>::max)();
        cout << "			minValue:" << (numeric_limits<unsigned long>::min)() << endl;
    
        cout << "double: 		" << "numOfBytes:" << sizeof(double);
        cout << "		maxValue:" << (numeric_limits<double>::max)();
        cout << "			minValue:" << (numeric_limits<double>::min)() << endl;
    
        cout << "long double: 		" << "numOfBytes:" << sizeof(long double);
        cout << "		maxValue:" << (numeric_limits<long double>::max)();
        cout << "			minValue:" << (numeric_limits<long double>::min)() << endl;
    
        cout << "float: 			" << "numOfBytes:" << sizeof(float);
        cout << "		maxValue:" << (numeric_limits<float>::max)();
        cout << "			minValue:" << (numeric_limits<float>::min)() << endl;
    
        cout << "size_t: 		" << "numOfBytes:" << sizeof(size_t);
        cout << "		maxValue:" << (numeric_limits<size_t>::max)();
        cout << "		minValue:" << (numeric_limits<size_t>::min)() << endl;
    
        cout << "			" << "************size**************" << endl;
        return 0;
    }
    

  • 相关阅读:
    centos7安装docker
    spring成神之路第四十三篇:spring 中编程式事务怎么用的?
    spring成神之路第四十二篇:玩转 JdbcTemplate
    spring成神之路第四十一篇:@EnableCaching 集成 redis 缓存
    spring成神之路第四十篇:缓存使用(@EnableCaching、@Cacheable、@CachePut、@CacheEvict、@Caching、@CacheConfig)
    spring成神之路第三十八篇:@Scheduled & @EnableScheduling 定时器详解
    spring成神之路第三十七篇:@EnableAsync & @Async 实现方法异步调用
    spring成神之路第三十六篇:@EnableAspectJAutoProxy、@Aspect 中通知顺序详解
    spring成神之路第三十五篇:@Aspect 中 5 中通知详解
    spring成神之路第三十四篇:@Aspect 中@Pointcut 12 种用法
  • 原文地址:https://www.cnblogs.com/flyingrun/p/13485201.html
Copyright © 2020-2023  润新知