= Data Types = ''Part of'' TutorialFundamentals == Description == Shows how the `sizeof`, `min`, and `max` properties can reveal the size and possible minimum/maximum values of the data types. == Example == {{{ #!d import std.stdio; int main() { // Show information about integer types... writefln("bool\tmin: %d\tmax: %d (%d)", bool.min, bool.max, bool.sizeof); writefln("ubyte\tmin: %d\tmax: %d (%d)", ubyte.min, ubyte.max, ubyte.sizeof); writefln("ushort\tmin: %d\tmax: %d (%d)", ushort.min, ushort.max, ushort.sizeof); writefln("uint\tmin: %d\tmax: %d (%d)", uint.min, uint.max, uint.sizeof); writefln("ulong\tmin: %d\tmax: %d (%d)\n", ulong.min, ulong.max, ulong.sizeof); writefln("byte\tmin: %d\tmax: %d (%d)", byte.min, byte.max, byte.sizeof); writefln("short\tmin: %d\tmax: %d (%d)", short.min, short.max, short.sizeof); writefln("int\tmin: %d\tmax: %d (%d)", int.min, int.max, int.sizeof); writefln("long\tmin: %d\tmax: %d (%d)\n", long.min, long.max, long.sizeof); // Show information about floating-point types... writef("float (%d)\tdouble (%d)\treal (%d)\t", float.sizeof, double.sizeof, real.sizeof); writef("ifloat (%d)\tidouble (%d)\tireal (%d)\t", ifloat.sizeof, idouble.sizeof, ireal.sizeof); writef("cfloat (%d)\tcdouble (%d)\tcreal (%d)\t", cfloat.sizeof, cdouble.sizeof, creal.sizeof); // Show information about character types... writef("char (%d)\twchar (%d)\tdchar (%d)\t", char.sizeof, wchar.sizeof, dchar.sizeof); return 0; } }}} == Output == {{{ bool min: 0 max: 1 (1) ubyte min: 0 max: 255 (1) ushort min: 0 max: 65535 (2) uint min: 0 max: 4294967295 (4) ulong min: 0 max: 18446744073709551615 (8) byte min: -128 max: 127 (1) short min: -32768 max: 32767 (2) int min: -2147483648 max: 2147483647 (4) long min: -9223372036854775808 max: 9223372036854775807 (8) float (4) double (8) real (10) ifloat (4) idouble (8) ireal (10) cfloat (8) cdouble (16) creal (20) cfloat (8) cdouble (16) creal (20) char (1) wchar (2) dchar (4) }}} == More Information == === Integer Types === || '''Type''' || '''Min''' || '''Max''' || '''Size (bytes)''' || || bool || 0 || 1 || 1 || || ubyte || 0 || 255 || 1 || || ushort || 0 || 65,535 || 2 || || uint || 0 || 4,294,967,295 || 4 || || ulong || 0 || 18,446,744,073,709,551,615 || 8 || || byte || -128 || 127 || 1 || || short || -32,768 || 32,767 || 2 || || int || -2,147,483,648 || 2,147,483,647 || 4 || || long || -9,223,372,036,854,775,808 || 9,223,372,036,854,775,807 || 8 || === Floating-Point Types === * Floating point: * float * double * real * Complex and Imaginary: * cfloat * cdouble * creal * Complex and Imaginary: * ifloat * idouble * ireal === Character Types === * char: unsigned 8 bit (UTF-8) * wchar: unsigned 16 bit (UTF-16) * dchar: unsigned 32 bit (UTF-32) The official list is in the [http://www.digitalmars.com/d/type.html D Specification]. == Source == Based on [http://jcc_7.tripod.com/d/tutor/types.html types.html] by jcc7.