TITLE
    Data Type Storage Sizes for Mach
Article ID:
Created:
Modified:
71432
9/15/98
11/10/99

TOPIC

    This article discusses the sizes of the fundamental C data types under the Mach operating system.


DISCUSSION

    Q: How many bytes of storage do the various fundamental data types require under OPENSTEP for Mach? What are the maximum and minimum values for the various arithmetic data types?

    A:

    TYPE SIZE MINIMUM MAXIMUM
    char 1 byte = 8 bits -128 127
    unsigned char 1 byte = 8 bits 0 255
    short 2 bytes = 16 bits -32768 32767
    unsigned short 2 bytes = 16 bits 0 65535
    int 4 bytes = 32 bits -2147483648 2147483647
    long 4 bytes = 32 bits -2147483648 2147483647
    unsigned int 4 bytes = 32 bits 0 4294967295
    unsigned long 4 bytes = 32 bits 0 4294967295
    float 4 bytes = 32 bits 1.17549435e-38f 3.40282347e+38f
    double 8 bytes = 64 bits 2.225073858507201e-308 1.797693134862316e+308
    • The unsigned and signed keywords don't change the size of the type they qualify.
    • Pointers occupy 4 bytes.
    • The void type occupies no space.

    If you happen to forget any of the sizes, you can quickly remind yourself by running gdb and typing:

    print sizeof(type)

    The minimum and maximum values are defined as constants in <limits.h> and <float.h> .

    The NeXTSTEP mach implementation used the same values.


Document Information
Product Area: Apple Software
Category: NeXTSTEP; OPENSTEP
Sub Category: Development

Copyright © 2000 Apple Computer, Inc. All rights reserved.