added datatypes D example
git-svn-id: svn://anubis/misc/d@88 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
675e312f25
commit
b3c622aa39
12
datatypes/Makefile
Normal file
12
datatypes/Makefile
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
TARGET := datatypes
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
$(TARGET): $(TARGET).d
|
||||||
|
|
||||||
|
%: %.d
|
||||||
|
gdc -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f *.o *~ $(TARGET)
|
39
datatypes/datatypes.d
Normal file
39
datatypes/datatypes.d
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
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...
|
||||||
|
writefln("float (%d)\tdouble (%d)\treal (%d)",
|
||||||
|
float.sizeof, double.sizeof, real.sizeof);
|
||||||
|
writefln("ifloat (%d)\tidouble (%d)\tireal (%d)",
|
||||||
|
ifloat.sizeof, idouble.sizeof, ireal.sizeof);
|
||||||
|
writefln("cfloat (%d)\tcdouble (%d)\tcreal (%d)",
|
||||||
|
cfloat.sizeof, cdouble.sizeof, creal.sizeof);
|
||||||
|
|
||||||
|
// Show information about character types...
|
||||||
|
writefln("char (%d)\twchar (%d)\tdchar (%d)",
|
||||||
|
char.sizeof, wchar.sizeof, dchar.sizeof);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user