Note: This website is archived. For up-to-date information about D projects and development, please visit

Data Types

Part of TutorialFundamentals


Shows how the sizeof, min, and max properties can reveal the size and possible minimum/maximum values of the data types.


import std.stdio;

void main() 
    // Print out information about integer types
    writefln("(%d) bool    min: %20d  max: %20d",    bool.sizeof,   bool.min,   bool.max);  
    writefln("(%d) ubyte   min: %20d  max: %20d",   ubyte.sizeof,  ubyte.min,  ubyte.max);  
    writefln("(%d) ushort  min: %20d  max: %20d",  ushort.sizeof, ushort.min, ushort.max);  
    writefln("(%d) uint    min: %20d  max: %20d",    uint.sizeof,   uint.min,   uint.max);  
    writefln("(%d) ulong   min: %20d  max: %20d\n", ulong.sizeof,  ulong.min,  ulong.max);    
    writefln("(%d) byte    min: %20d  max: %20d",    byte.sizeof,  byte.min,  byte.max);  
    writefln("(%d) short   min: %20d  max: %20d",   short.sizeof, short.min, short.max);    
    writefln("(%d) int     min: %20d  max: %20d",     int.sizeof,   int.min,   int.max);    
    writefln("(%d) long    min: %20d  max: %20d\n",  long.sizeof,  long.min,  long.max);    

    // Show information about floating-point types...
    writefln("(%d) float\t(%d) double\t(%d) real", float.sizeof,  double.sizeof,  real.sizeof);

    // Show information about character types...
    writefln("(%d) char\t(%d) wchar\t(%d) dchar", char.sizeof, wchar.sizeof, dchar.sizeof);


(1) bool    min:                    0  max:                    1
(1) ubyte   min:                    0  max:                  255
(2) ushort  min:                    0  max:                65535
(4) uint    min:                    0  max:           4294967295
(8) ulong   min:                    0  max: 18446744073709551615

(1) byte    min:                 -128  max:                  127
(2) short   min:               -32768  max:                32767
(4) int     min:          -2147483648  max:           2147483647
(8) long    min: -9223372036854775808  max:  9223372036854775807

(4) float       (8) double      (10) real
(1) char        (2) wchar       (4) dchar

More Information

For more information refer to the official list of D2 types in the D2 Specification.


Based on types.html by jcc7.