zoukankan      html  css  js  c++  java
  • 常用数据类型占内存字节数

    常用基本数据类型占内存的字节数:
    32位编译器:(指针类型的所占字节数在32位的寻址空间是2^32, 即32个bit,也就是4个字节。同理64位编译器)
    int:4个字节
    int *:4个字节
    short int:2个字节
    unsigned int:4个字节
    long:4个字节
    long *:4个字节
    unsigned long:4个字节
    long long:8个字节
    char:1个字节
    char *:4个字节
    float:4个字节
    double:8个字节
    32位编译器结果

    64位编译器:(指针类型的所占字节数在64位的寻址空间是2^64, 即64个bit,也就是8个字节。同理32位编译器)
    int:4个字节
    int *:8个字节
    short int:2个字节
    unsigned int:4个字节
    long:8个字节
    long *:8个字节
    unsigned long:8个字节
    long long:8个字节
    char:1个字节
    char *:8个字节
    float:4个字节
    double:8个字节
    64位编译器结果

    补充:
    java中常用八种复杂数据类型的字节数(32位系统和64位系统一样):
    Integer: 4字节
    Short: 2字节
    Long: 8字节
    Byte: 1字节
    Character: 2字节
    Float: 4字节
    Double: 8字节
    Boolean:不确定
    可用下述代码查出占内存的字节数:

      System.out.println("Integer: " + Integer.SIZE/8);// 4    
      System.out.println("Short: " + Short.SIZE/8); // 2        
      System.out.println("Long: " + Long.SIZE/8);   // 8    
      System.out.println("Byte: " + Byte.SIZE/8);  // 1
      System.out.println("Character: "+Character.SIZE/8);//2
      System.out.println("Float: " + Float.SIZE/8);   // 4    
      System.out.println("Double: " + Double.SIZE/8); // 8
    
    不积跬步,无以至千里;不积小流,无以成江海。
  • 相关阅读:
    Hadoop书籍介绍
    WeakReference,SoftReference 和 PhatomReference 浅析
    如何在Java中定义常量(Constant)
    也谈谈Java的垃圾收集(garbage collection)
    csdn的新家
    安装和使用Oracle Instant Client 和 SQLPlus
    Perl中的grep和map
    用Devel::NYTProf 优化perl脚本性能
    DataBase
    Linux下配置listener和tns
  • 原文地址:https://www.cnblogs.com/xiaocai-ios/p/7779803.html
Copyright © 2011-2022 走看看