zoukankan      html  css  js  c++  java
  • 数据

    gcc版本

    Using built-in specs.
    Target: x86_64-redhat-Linux
    Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,Java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
    Thread model: posix
    gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. /*.int数据类型int类型数据所占内存空间为32位。 
    2. 其中有符号整型变量取值范围为-2147483648~2147483647, 
    3. 无符号型整型变量取值范围为0~4294967295U. 
    4. */  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. int ia = 2147483647;//int 最大值不越界  
    2. int iaOver = 2147483647+1;//越界  
    3. //32 64位编译结果一样  
    4. cout <<"ia不越界:"<<ia<<endl;//ia不越界:2147483647    
    5. cout <<"iaOver越界:"<<iaOver<<endl;//iaOver越界:-2147483648  
    6. //32 位编译unsigned int   
    7. unsigned int uia = 4294967295;  
    8. unsigned int uiau = 4294967295u;  
    9. unsigned int uiOver = 4294967295+1;  
    10. unsigned int uiOveru = 4294967295+1u;  
    11. cout <<"uia不越界:"<<uia<<endl;//4294967295  
    12. cout <<"uiau不越界:"<<uiau<<endl;//4294967295  
    13. cout <<"uiOver越界:"<<uiOver<<endl;//0  
    14. cout <<"uiOver越界:"<<uiOveru<<endl;//0  */  
    15. /*32编译结果 
    16. int_long_32_64.cpp:17: warning: this decimal constant is unsigned only in ISO C90 
    17. int_long_32_64.cpp:19: warning: this decimal constant is unsigned only in ISO C90 
    18. int_long_32_64.cpp:20: warning: this decimal constant is unsigned only in ISO C90 
    19. */  
    20. //64 位编译unsigned int   
    21. unsigned int uia = 4294967295;  
    22. unsigned int uiau = 4294967295u;  
    23. unsigned int uiOver = 4294967295+1;  
    24. unsigned int uiOveru = 4294967295+1u;  
    25. cout <<"uia不越界:"<<uia<<endl;//4294967295  
    26. cout <<"uiau不越界:"<<uiau<<endl;//4294967295  
    27. cout <<"uiOver越界:"<<uiOver<<endl;//0  
    28. cout <<"uiOver越界:"<<uiOveru<<endl;//0  
    29. //64编译结果  
    30. /*int_long_32_64.cpp:34: warning: large integer implicitly truncated to unsigned type 
    31. int_long_32_64.cpp:35: warning: large integer implicitly truncated to unsigned type 
    32. */  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //long int数据类型   
    2. /* 
    3. 随着宏__WORDSIZE值的改变,long int数据类型的大小也会发生改变。 
    4. 如果__WORDSIZE的值为32,则long int和int类型一样,占有32位。 
    5. 在Linux GCC4.0-i386版本中,默认情况下__WORDSIZE的值为32.其定义如下: 
    6. #include</usr/include/bits/wordsize.h> 
    7. #define __WORDSIZE 32  
    8. 在64位机器上,如果__WORDSIZE的值为64,  
    9. long int类型数据所占内存空间为64位。 
    10. 其中有长整型变量取值范围为-9223372036854775808L~9223372036854775807L, 
    11. 无符号长整型变量取值范围为0~18446744073709551615UL.其限制如下:  
    12. */  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //32 位编译long   
    2. cout<<"查看机器编译器位数:"<<__WORDSIZE<<endl;//32  
    3. long la = 2147483647;  
    4. long laOver = 2147483647+1;  
    5. long lal = 2147483647l;  
    6. long laOverl = 2147483647+1l;  
    7. cout <<"la不越界:"<<la<<endl;//2147483647  
    8. cout <<"laOver越界:"<<laOver<<endl;//-2147483648  
    9. cout <<"lal不越界:"<<lal<<endl;//0  
    10. cout <<"laOverl越界:"<<laOverl<<endl;//-2147483648  
    11. //32编译结果  
    12. int_long_32_64.cpp: In function ‘int main()’:  
    13. int_long_32_64.cpp:663: warning: overflow in implicit constant conversion  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //64 位编译long   
    2. cout<<"查看机器编译器位数:"<<__WORDSIZE<<endl;//64  
    3. long la = 2147483647;  
    4. long laOver = 2147483647+1;  
    5. long lal = 2147483647l;  
    6. long laOverl = 2147483647+1l;  
    7. cout <<"la不越界:"<<la<<endl;//2147483647  
    8. cout <<"laOver越界:"<<laOver<<endl;//-2147483648 数据末尾未加l(小写L)系统默认为int越界  
    9. cout <<"lal不越界:"<<lal<<endl;//0  
    10. cout <<"laOverl越界:"<<laOverl<<endl;//2147483648 64位机器此处不越界  
    11. //64 位编译结果  
    12. int_long_32_64.cpp: In function ‘int main()’:  
    13. int_long_32_64.cpp:78: warning: overflow in implicit constant conversion  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //由于64位的编译器long占8*8位所以将long的最大值进行测试  
    2. /* 
    3. 在64位机器上,如果__WORDSIZE的值为64, long int类型数据所占内存空间为64位。 
    4. 其中有长整型变量取值范围为-9223372036854775808L~9223372036854775807L, 
    5. 无符号长整型变量取值范围为0~18446744073709551615UL. 
    6. */  
    7. cout<<"查看机器编译器位数:"<<__WORDSIZE<<endl;//64  
    8. long la64 = 9223372036854775807;  
    9. long laOver64 = 9223372036854775807+1;  
    10. long lal64 = 9223372036854775807l;  
    11. long laOverl64 = 9223372036854775807+1l;  
    12. cout <<"la64不越界:"<<la64<<endl;//9223372036854775807  
    13. cout <<"laOver64越界:"<<laOver64<<endl;//-9223372036854775808   
    14. cout <<"lal64不越界:"<<lal64<<endl;//9223372036854775807  
    15. cout <<"laOverl64越界:"<<laOverl64<<endl;//-9223372036854775808   
    16. //64编译 无问题  
    17. //32位编译  
    18. /*全部越界 
    19. int_long_32_64.cpp:97: warning: overflow in implicit constant conversion 
    20. int_long_32_64.cpp:98: warning: overflow in implicit constant conversion 
    21. int_long_32_64.cpp:99: warning: overflow in implicit constant conversion 
    22. int_long_32_64.cpp:100: warning: overflow in implicit constant conversion 
    23. */  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //32 unsinged long   
    2. /*.int/long数据类型int/long类型数据所占内存空间为32位。 
    3. 无符号型整型变量取值范围为0~4294967295U. 
    4. */  
    5. unsigned long ul32 = 4294967295;  
    6. unsigned long ulaOver32 = 4294967295u;  
    7. unsigned long ulal32 = 4294967295+1;  
    8. unsigned long ulaOverl32 = 4294967295+1u;  
    9. cout <<"ul32不越界:"<<ul32<<endl;//4294967295  
    10. cout <<"ulaOver32不越界:"<<ulaOver32<<endl;//4294967295  
    11. cout <<"ulal32越界:"<<ulal32<<endl;//0  
    12. cout <<"ulaOverl32越界:"<<ulaOverl32<<endl;//0  
    13.   
    14. /*32编译结果 
    15. int_long_32_64.cpp:122: warning: this decimal constant is unsigned only in ISO C90 
    16. int_long_32_64.cpp:124: warning: this decimal constant is unsigned only in ISO C90 
    17. int_long_32_64.cpp:125: warning: this decimal constant is unsigned only in ISO C90 
    18. */  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //64 unsinged long   
    2. //无符号长整型变量取值范围为0~18446744073709551615UL.  
    3. //其中有长整型变量取值范围为-9223372036854775808L~9223372036854775807L,  
    4. unsigned long ul64 = 4294967295;  
    5. unsigned long ulaOver64 = 4294967295u;  
    6. unsigned long ulal64 = 4294967295+1;  
    7. unsigned long ulaOverl64 = 4294967295+1u;  
    8. cout <<"ul64不越界:"<<ul64<<endl;//4294967295  
    9. cout <<"ulaOver64不越界:"<<ulaOver64<<endl;//4294967295  
    10. cout <<"ulal64不越界:"<<ulal64<<endl;//4294967296  
    11. cout <<"ulaOverl64不越界:"<<ulaOverl64<<endl;//4294967296  
    12. /*64编译结果 
    13. 正常无错 
    14. */  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. unsigned long ula64_2 = 18446744073709551615;  
    2. unsigned long ula64_2u = 18446744073709551615u;  
    3. unsigned long ula64Over_2 = 18446744073709551615+1;  
    4. unsigned long ula64Over_2u = 18446744073709551615+1u;  
    5. cout <<"ula64_2不越界:"<<ula64_2<<endl;//18446744073709551615  
    6. cout <<"ula64_2u不越界:"<<ula64_2u<<endl;//18446744073709551615                                             
    7. cout <<"ula64Over_2越界:"<<ula64Over_2<<endl;//0  
    8. cout <<"ula64Over_2u越界:"<<ula64Over_2u<<endl;//0  
    9. //64编译结果  
    10. int_long_32_64.cpp:149:25: warning: integer constant is so large that it is unsigned  
    11. int_long_32_64.cpp:149: warning: this decimal constant is unsigned only in ISO C90  
    12. int_long_32_64.cpp:151:29: warning: integer constant is so large that it is unsigned  
    13. int_long_32_64.cpp:151: warning: this decimal constant is unsigned only in ISO C90  
    14. int_long_32_64.cpp:152:30: warning: integer constant is so large that it is unsigned  
    15. int_long_32_64.cpp:152: warning: this decimal constant is unsigned only in ISO C90  
    16. */  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //32位 long long   
    2.   
    3. cout<<"32位编译器 long long占:"<<sizeof(long long)<<endl;//8  
    4. //32位的long long 与64位的long 最大数值一样  
    5. //取值范围为-9223372036854775808L~9223372036854775807LL,  
    6. long long lla32 = 9223372036854775807ll;//不加ll错误 过不去  
    7. //long long llaOver32 = 9223372036854775807+1ll;//编译错误 过不去  
    8. cout <<"lla32不越界:"<<lla32<<endl;//9223372036854775807  
    9. //cout <<"llaOver32越界:"<<llaOver32<<endl;//  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //64位 long long   
    2. cout<<"64位编译器 long long占:"<<sizeof(long long)<<endl;//8  
    3. //32位的long long 与64位的long 最大数值一样  
    4. //取值范围为-9223372036854775808L~9223372036854775807LL,  
    5. long long lla32 = 9223372036854775807;//9223372036854775807ll  
    6. long long llaOver32 = 9223372036854775807+1;//9223372036854775807+1ll  
    7. cout <<"lla32不越界:"<<lla32<<endl;//9223372036854775807  
    8. cout <<"llaOver32越界:"<<llaOver32<<endl;//-9223372036854775808  
    9. //64位编译结果  
    10. //数据结尾加不加ll都一样,可通过  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //32位 unsigned long long   
    2. cout<<"32位编译器 unsigned long long占:"<<sizeof(unsigned long long)<<endl;//8  
    3. unsigned long long ulla32 = 18446744073709551615ull;//不加ull错误 过不去  
    4. //long long ullaOver32 = 18446744073709551615+1ull;//编译错误 过不去  
    5. cout <<"ulla32不越界:"<<ulla32<<endl;//18446744073709551615  
    6. //cout <<"ullaOver32越界:"<<ullaOver32<<endl;  
    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
    1. //64位 unsigned long long   
    2. cout<<"64位编译器 unsigned long long占:"<<sizeof(unsigned long long)<<endl;//8  
    3. unsigned long long ulla64 = 18446744073709551615;//  
    4. long long ullaOver64 = 18446744073709551615+1ull;//0  
    5. cout <<"ulla64不越界:"<<ulla64<<endl;//18446744073709551615  
    6. cout <<"ullaOver64越界:"<<ullaOver64<<endl;   

    直接gcc test.c不加参数默认为编译器位数,本机为64位;

    gcc test.c -m32 按32位编译器编译,反之在64位机上gcc test.c -m64

    [cpp] view plain copy
     
     在CODE上查看代码片派生到我的代码片
      1. 常用数据类型对应字节数  
      2.    可用如sizeof(char),sizeof(char*)等得出   
      3.   
      4.  32位编译器:  
      5.    
      6.       char :1个字节  
      7.        char*(即指针变量): 4个字节(32位的寻址空间是2^32, 即32个bit,也就是4个字节。同理64位编译器)  
      8.        short int : 2个字节  
      9.        int:  4个字节  
      10.        unsigned int : 4个字节  
      11.        float:  4个字节  
      12.        double:   8个字节  
      13.        long:   4个字节  
      14.        long long:  8个字节  
      15.        unsigned long:  4个字节  
      16.    
      17.   
      18.   64位编译器:  
      19.    
      20.       char :1个字节  
      21.        char*(即指针变量): 8个字节  
      22.        short int : 2个字节  
      23.        int:  4个字节  
      24.        unsigned int : 4个字节  
      25.        float:  4个字节  
      26.        double:   8个字节  
      27.        long:   8个字节  
      28.        long long:  8个字节  
      29.        unsigned long:  8个字节  
      30.    
  • 相关阅读:
    转--后台开发人员的技术栈
    hadoop +streaming 排序总结
    python 的tempfile学习
    hadoop学习日志
    shell sort 排序大讨论
    系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式
    推荐系统评测指标--准确率(Precision)和召回率(Recall)、F值(F-Measure)
    shell 数组
    leecode第七百四十六题(使用最小花费爬楼梯)
    leecode第四百七十五题(供暖器)
  • 原文地址:https://www.cnblogs.com/tianxxl/p/6492540.html
Copyright © 2011-2022 走看看