Data Type Storage Sizes for Mach

This article discusses the sizes of the fundamental C data types under the Mach operating system.
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:
TYPESIZEMINIMUMMAXIMUM
char1 byte = 8 bits -128 127
unsigned char1 byte = 8 bits 0 255
short2 bytes = 16 bits -32768 32767
unsigned short2 bytes = 16 bits 065535
int4 bytes = 32 bits -2147483648 2147483647
long 4 bytes = 32 bits -2147483648 2147483647
unsigned int4 bytes = 32 bits 04294967295
unsigned long 4 bytes = 32 bits 04294967295
float 4 bytes = 32 bits 1.17549435e-38f3.40282347e+38f
double8 bytes = 64 bits2.225073858507201e-3081.797693134862316e+308

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.
Published Date: Feb 20, 2012