zoukankan      html  css  js  c++  java
  • c c++各种类型的取值范围

    int类型的变量存储值从-2147483648到2147483647

    1 //例子
    2 #include <iostream>
    3 2 using namespace std;
    4 3 int main(void)
    5 4 {
    6 5 
    7 6     cout<<"int类型的取值范围为:"<<INT_MIN<<""<<INT_MAX<<endl;
    8 7     return 0;
    9 8 }

    unsigned int类型的变量存储值从0到4294967295

    1 //例子
    2 #include <iostream>
    3 using namespace std;
    4 int main(void)
    5 {
    6     cout<<"unsigned int类型的取值范围为:0到"<<UINT_MAX<<endl;
    7     return 0;
    8 }

    short类型的变量存储值从-32768到32767

    unsigned short类型的变量存储值从0到65535


    char类型的变量存储值从-128到127
    unsigned char类型的变量存储值从0到255


    long类型的变量存储值从-2147483648到2147483647
    unsigned long类型的变量存储值从0到4294967295
    long long类型的变量存储值从-9223372036854775808到9223372036854775807
    unsigned long long类型的变量存储值从0到18446744073709551615

    最小的非零float类型变量的值的是1.175e-038
    最大的float类型变量的值的是3.403e+038
    最小的非零double类型变量的值的是2.225e-308
    最大的double类型变量的值的是1.798e+308
    最小的非零long double类型变量的值的是-0.000e+000
    最大的long double类型变量的值的是-1.#QOe+000
    float类型的变量提供6位精度的小数位数
    double类型的变量提供15位精度的小数位数
    long double类型的变量提供18位精度的小数位数

     1 #include <stdio.h>
     2 #include <limits.h>
     3 #include <float.h>
     4 #include <stdlib.h>
     5 int main(void)
     6 
     7 {
     8 
     9     printf("char类型的变量存储值从%d到%d
    ", CHAR_MIN, CHAR_MAX);
    10 
    11     printf("unsigned char类型的变量存储值从0到%u
    ", UCHAR_MAX);
    12 
    13     printf("short类型的变量存储值从%d到%d
    ", SHRT_MIN, SHRT_MAX);
    14 
    15     printf("unsigned short类型的变量存储值从0到%u
    ", USHRT_MAX);
    16 
    17     printf("int类型的变量存储值从%d到%d
    ", INT_MIN, INT_MAX);
    18 
    19     printf("unsigned int类型的变量存储值从0到%u
    ", UINT_MAX);
    20 
    21     printf("long类型的变量存储值从%ld到%ld
    ", LONG_MIN, LONG_MAX);
    22 
    23     printf("unsigned long类型的变量存储值从0到%lu
    
    ", ULONG_MAX);
    24 
    25     printf("long long类型的变量存储值从%lld到%lld
    ", LLONG_MIN, LLONG_MAX);
    26 
    27     printf("unsigned long long类型的变量存储值从0到%llu
    ", ULLONG_MAX);
    28 
    29     printf("最小的非零float类型变量的值的是%.3e
    ", FLT_MIN);
    30 
    31     printf("最大的float类型变量的值的是%.3e
    ", FLT_MAX);
    32 
    33     printf("最小的非零double类型变量的值的是%.3e
    ", DBL_MIN);
    34 
    35     printf("最大的double类型变量的值的是%.3e
    
    ", DBL_MAX);
    36 
    37     printf("最小的非零long double类型变量的值的是%.3Le
    ", LDBL_MIN);
    38 
    39     printf("最大的long double类型变量的值的是%.3Le
    ", LDBL_MAX);
    40 
    41     printf("float类型的变量提供%u位精度的小数位数
    ", FLT_DIG);
    42 
    43     printf("double类型的变量提供%u位精度的小数位数
    
    ", DBL_DIG);
    44 
    45     printf("long double类型的变量提供%u位精度的小数位数
    ", LDBL_DIG);
    46 
    47     system("pause");
    48 
    49     return 0;
    50 }
     1 #include<iostream>
     2 #include<string>
     3 #include <limits>
     4 using namespace std;
     5 
     6 int main()
     7 {
     8 
     9     cout << "type: 		" << "************size**************"<< endl;
    10     cout << "bool: 		" << "所占字节数:" << sizeof(bool);
    11     cout << "	最大值:" << (numeric_limits<bool>::max)();
    12     cout << "		最小值:" << (numeric_limits<bool>::min)() << endl;
    13     cout << "char: 		" << "所占字节数:" << sizeof(char);
    14     cout << "	最大值:" << (numeric_limits<char>::max)();
    15     cout << "		最小值:" << (numeric_limits<char>::min)() << endl;
    16     cout << "signed char: 	" << "所占字节数:" << sizeof(signed char);
    17     cout << "	最大值:" << (numeric_limits<signed char>::max)();
    18     cout << "		最小值:" << (numeric_limits<signed char>::min)() << endl;
    19     cout << "unsigned char: 	" << "所占字节数:" << sizeof(unsigned char);
    20     cout << "	最大值:" << (numeric_limits<unsigned char>::max)();
    21     cout << "		最小值:" << (numeric_limits<unsigned char>::min)() << endl;
    22     cout << "wchar_t: 	" << "所占字节数:" << sizeof(wchar_t);
    23     cout << "	最大值:" << (numeric_limits<wchar_t>::max)();
    24     cout << "		最小值:" << (numeric_limits<wchar_t>::min)() << endl;
    25     cout << "short: 		" << "所占字节数:" << sizeof(short);
    26     cout << "	最大值:" << (numeric_limits<short>::max)();
    27     cout << "		最小值:" << (numeric_limits<short>::min)() << endl;
    28     cout << "int: 		" << "所占字节数:" << sizeof(int);
    29     cout << "	最大值:" << (numeric_limits<int>::max)();
    30     cout << "	最小值:" << (numeric_limits<int>::min)() << endl;
    31     cout << "unsigned: 	" << "所占字节数:" << sizeof(unsigned);
    32     cout << "	最大值:" << (numeric_limits<unsigned>::max)();
    33     cout << "	最小值:" << (numeric_limits<unsigned>::min)() << endl;
    34     cout << "long: 		" << "所占字节数:" << sizeof(long);
    35     cout << "	最大值:" << (numeric_limits<long>::max)();
    36     cout << "	最小值:" << (numeric_limits<long>::min)() << endl;
    37     cout << "unsigned long: 	" << "所占字节数:" << sizeof(unsigned long);
    38     cout << "	最大值:" << (numeric_limits<unsigned long>::max)();
    39     cout << "	最小值:" << (numeric_limits<unsigned long>::min)() << endl;
    40     cout << "double: 	" << "所占字节数:" << sizeof(double);
    41     cout << "	最大值:" << (numeric_limits<double>::max)();
    42     cout << "	最小值:" << (numeric_limits<double>::min)() << endl;
    43     cout << "long double: 	" << "所占字节数:" << sizeof(long double);
    44     cout << "	最大值:" << (numeric_limits<long double>::max)();
    45     cout << "	最小值:" << (numeric_limits<long double>::min)() << endl;
    46     cout << "float: 		" << "所占字节数:" << sizeof(float);
    47     cout << "	最大值:" << (numeric_limits<float>::max)();
    48     cout << "	最小值:" << (numeric_limits<float>::min)() << endl;
    49     cout << "size_t: 	" << "所占字节数:" << sizeof(size_t);
    50     cout << "	最大值:" << (numeric_limits<size_t>::max)();
    51     cout << "	最小值:" << (numeric_limits<size_t>::min)() << endl;
    52     cout << "string: 	" << "所占字节数:" << sizeof(string) << endl;
    53     // << "	最大值:" << (numeric_limits<string>::max)() << "	最小值:" << (numeric_limits<string>::min)() << endl;
    54     cout << "type: 		" << "************size**************"<< endl;
    55     return 0;
    56 }
  • 相关阅读:
    python3 TypeError: a bytes-like object is required, not 'str'
    Centos 安装Python Scrapy PhantomJS
    Linux alias
    Vim vimrc配置
    Windows下 Python Selenium PhantomJS 抓取网页并截图
    Linux sort
    Linux RSync 搭建
    SSH隧道 访问内网机
    笔记《鸟哥的Linux私房菜》7 Linux档案与目录管理
    Tornado 错误 "Global name 'memoryview' is not defined"
  • 原文地址:https://www.cnblogs.com/didiaodidiao/p/9147643.html
Copyright © 2011-2022 走看看