added datatypes D example

git-svn-id: svn://anubis/misc/d@88 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2009-02-14 19:54:51 +00:00
parent 675e312f25
commit b3c622aa39
2 changed files with 51 additions and 0 deletions

12
datatypes/Makefile Normal file
View 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
View 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;
}