All variables in the D programming language must be of a particular data type. All data types have similar properties, for example, size, minimum value, maximum value, and so on.
We can access the properties of each of these data types with a dot after the name of the type, followed by the name of the property to access.
For example, the sizeof
property of char
data type is accessed as char.sizeof
.
Let’s check out some of these properties below:
.stringof
: Returns the name of the data type as a string..sizeof
: Returns the bytes length of a particular data type. To know the bit count, multiply the returned value by 8, the number of bits in a byte..min
: Stands for the minimum. And it shows the smallest value that a data type can have..max
: Stands for the maximum. And it indicates the largest value that a data type can hold..init
: Means the initial value. The default value D will assign to a data type if an initial value is not provided.Below is a code snippet that prints all properties of the data type int
:
import std.stdio;void main() {/*details for data type int*/writeln("Type : ", int.stringof);writeln("Length in bytes: ", int.sizeof);writeln("Minimum value : ", int.min);writeln("Maximum value : ", int.max);writeln("Initial value : ", int.init);}
stdio
module to print to display.main
program wrapper function, and it ends on line 11.int
data type are returned and displayed using the writeln
function.