Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

D Programming/Types

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

To be completed. a) create a table for data types b) explain them. D Data Types If you look directly at the content of a computer's memory, you see only a lot of bytes. These are often shown as numbers but in fact they don't have a meaning on its own, not even the meaning of a number. Types are used in computer languages like D to give one byte or a sequence of bytes a meaning. Types define if these bytes are a number, a text, a date or whatever. Basic Types Void Type void Boolean Type bool Integer Types Provided types are: byte ubyte short ushort int uint long ulong cent (reserved for future use) ucent (reserved for future use) Each type has a size in bits which defines how many different values(=states) it can hold. An 8 bit type, for instance, can store 256 different states, while a 16 bit type can store 65536. The sizes of the types are: Name Size in bits Size in octets Min Maxbyte81 -128 +127ubyte 8 1 0 +255short162 -32,768 +32,767ushort 16 2 0 +65,535int324 -2,147,483,648 +2,147,483,647uint 32 4 0 +4,294,967,295long648 -9,223,372,036,854,775,808 +9,223,372,036,854,775,807ulong 64 8 0 +18,446,744,073,709,551,615cent12816 -170,141,183,460,469,231,731,687,303,715,884,105,728 +170,141,183,460,469,231,731,687,303,715,884,105,727 Each type exists as signed and unsigned variant. The unsigned ones have an "u" prefix (like uint, ubyte). Unsigned means that the range of possible states is interpreted as nonnegative values starting at 0 and going up to the maximum number of possible states for this type minus 1 because the 0 is also a state which must be stored. For the ubyte type (8 bit = 256 states) this means it can store values from 0 up to and including 255. Signed types interpret one half of their states as positive, the other half as negative values, so the signed byte type has a range of values from -128 to +127. Floating-Point Types float double real ifloat idouble ireal cfloat cdouble creal Character Types A character is a unit of information that roughly corresponds to a grapheme-like unit, or symbol, such as in an alphabet in the written form of a natural language. The concept also includes control characters, such as carriage return. Characters are typically combined into strings. D language allows to directly handle Unicode strings. char (to handle UTF8 code units) wchar (to handle UTF16 code units) dchar (to handle UTF32 code units) Derived Types pointer array associative array function delegate User Defined Types alias typedef enum struct union class