2.8.2 Data Types and Sizes

D provides fundamental data types for integers and
floating-point constants. Arithmetic may only be performed on
integers in D programs. Floating-point constants may be used to
initialize data structures, but floating-point arithmetic is not
permitted in D. In Oracle Linux, D provides a 64-bit data model for use
in writing programs. However, a 32-bit data model is not
supported. The data model used when executing your program is
the native data model that is associated with the active
operating system kernel, which must also be 64-bit.

The names of the integer types and their sizes in the 64-bit
data model are shown in the following table. Integers are always
represented in twos-complement form in the native byte-encoding
order of your system.

Table 2.3 D Integer Data Types

Type Name

64-bit Size

char

1 byte

short

2 bytes

int

4 bytes

long

8 bytes

long long

8 bytes

Integer types can be prefixed with the signed or unsigned
qualifier. If no sign qualifier is present, it is assumed that
the type is signed. The D compiler also provides the type
aliases that are listed in the following table.

Table 2.4 D Integer Type Aliases

Type Name

Description

int8_t

1-byte signed integer

int16_t

2-byte signed integer

int32_t

4-byte signed integer

int64_t

8-byte signed integer

intptr_t

Signed integer of size equal to a pointer

uint8_t

1-byte unsigned integer

uint16_t

2-byte unsigned integer

uint32_t

4-byte unsigned integer

uint64_t

8-byte unsigned integer

uintptr_t

Unsigned integer of size equal to a pointer

These type aliases are equivalent to using the name of the
corresponding base type listed in the previous table and are
appropriately defined for each data model. For example, the
uint8_t type name is an alias for the type
unsigned char. See
Section 2.13, “Type and Constant Definitions” for information about how
to define your own type aliases for use in D programs.

Note

The predefined type aliases cannot be used in files that are
included by the preprocessor.

D provides floating-point types for compatibility with ANSI C
declarations and types. Floating-point operators are not
supported in D, but floating-point data objects can be traced
and formatted with the printf function. You
can use the floating-point types that are listed in the
following table.