1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
{ %VERSION=1.1 }
program testv8;
uses variants,varutils;
Procedure TestConvert(Var V : Variant);
Var
I64 : Int64;
LI : Longint;
SI : Smallint;
HI : Shortint;
Q : QWord;
C : Cardinal;
W : Word;
B : Byte;
R : Real;
D : Double;
E : Extended;
S : Single;
Bo : Boolean;
begin
DumpVariant(TVarData(V));
I64:=V;
Writeln('To Int64 : ',I64);
LI:=V;
Writeln('To Longint : ',LI);
SI:=V;
Writeln('To Smallint : ',SI);
HI:=V;
Writeln('To Shortint : ',HI);
Q:=V;
Writeln('To QWord : ',Q);
C:=V;
Writeln('To Cardinal : ',C);
W:=V;
Writeln('To Word : ',W);
B:=V;
Writeln('To Byte : ',B);
R:=V;
Writeln('To Real : ',R);
D := v;
Writeln('To Double : ',D);
E := v;
Writeln('To Extended : ',E);
S := v;
Writeln('To Single : ',S);
Bo := v;
Writeln('To Boolean : ',Bo);
end;
Procedure TestReal(R : Real);
Var
V : Variant;
begin
V:=R;
TestConvert(V);
V:=-R;
TestConvert(V);
end;
Procedure TestDouble(R : Double);
Var
V : Variant;
begin
V:=R;
TestConvert(V);
V:=-R;
TestConvert(V);
end;
Procedure TestSingle(R : Single);
Var
V : Variant;
begin
V:=R;
TestConvert(V);
V:=-R;
TestConvert(V);
end;
Procedure TestExtended(R : Extended);
Var
V : Variant;
begin
V:=R;
TestConvert(V);
V:=-R;
TestConvert(V);
end;
begin
TestReal(1.0E-1);
TestDouble(2.0E-2);
TestSingle(3.0E-3);
TestExtended(4.0E-4);
TestReal(1.0E1);
TestDouble(2.0E2);
TestSingle(3.0E3);
TestExtended(4.0E4);
TestReal(0.0);
TestDouble(0.0);
TestSingle(0.0);
TestExtended(0.0);
TestReal(1.0E-39);
TestDouble(2.0E-39);
TestSingle(3.0E-39);
TestExtended(4.0E-39);
end.
|