[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Precision Errors - Part 2



PureBytes Links

Trading Reference Links

Test Program for TS4.0

 
{ *******************************************************************

   System        : _Floating Point Test
  
   Last Edit     : 07/23/01

   Provided By   : Bob Fulks

   Description   : This System tests various aspects of the TradeStation
      floating point system.


********************************************************************}
Vars: V1(0), V2(0), V3(0), V4(0), V5(0), V6(0), V7(0), V8(0), V9(0);
Vars: C1(0), C2(0), C3(0), C4(0), C5(0), C6(0), C7(0), C8(0), C9(0);
Vars: X1(0), X2(0), X3(0), X4(0), X5(0), X6(0), X7(0), X8(0), X9(0);
Vars: Y1(0), Y2(0), Y3(0), Y4(0), Y5(0), Y6(0), Y7(0), Y8(0), Y9(0);


if LastBarOnChart then begin
   V1 = 1234567890.12345678;
   V2 = 12345678901.2345678;
   V3 = 123456789012.345678;
   V4 = 1234567890123.45678;
   V5 = 12345678901234.5678;
   V6 = 123456789012345.678;
   V7 = 1234567890123456.78;
   V8 = 12345678901234567.8;
   V9 = 99999999999999999.9;
   V9 = 100000000000000008.0090;  {Largest number it would allow}

   C1 = V1 / 1000000;
   C2 = V2 / 1000000;
   C3 = V3 / 1000000;
   C4 = V4 / 1000000;
   C5 = V5 / 1000000;
   C6 = V6 / 1000000;
   C7 = V7 / 1000000;
   C8 = V8 / 1000000;
   C9 = V9 / 1000000;

   X1 = IntPortion(C1);
   X2 = IntPortion(C2);
   X3 = IntPortion(C3);
   X4 = IntPortion(C4);
   X5 = IntPortion(C5);
   X6 = IntPortion(C6);
   X7 = IntPortion(C7);
   X8 = IntPortion(C8);
   X9 = IntPortion(C9);

   Y1 = FracPortion(C1);
   Y2 = FracPortion(C2);
   Y3 = FracPortion(C3);
   Y4 = FracPortion(C4);
   Y5 = FracPortion(C5);
   Y6 = FracPortion(C6);
   Y7 = FracPortion(C7);
   Y8 = FracPortion(C8);
   Y9 = FracPortion(C9);

   Print("");
   Print("Calc:", V1:20:2, X1:15:2, Y1:15:15);
   Print("Good:", "          1234567890.12","           1234.00","              0.567890123456780");   
   Print("");
   Print("Calc:", V2:20:2, X2:15:2, Y2:15:15);
   Print("Good:", "         12345678901.23","          12345.00","              0.678901234567800");   
   Print("");
   Print("Calc:", V3:20:2, X3:15:2, Y3:15:15);
   Print("Good:", "        123456789012.34","         123456.00","              0.789012345678000");   
   Print("");
   Print("Calc:", V4:20:2, X4:15:2, Y4:15:15);
   Print("Good:", "       1234567890123.45","        1234567.00","              0.890123456780000");   
   Print("");
   Print("Calc:", V5:20:2, X5:15:2, Y5:15:15);
   Print("Good:", "      12345678901234.56","       12345678.00","              0.901234567800000");   
   Print("");
   Print("Calc:", V6:20:2, X6:15:2, Y6:15:15);
   Print("Good:", "     123456789012345.67","      123456789.00","              0.012345678000000");   
   Print("");
   Print("Calc:", V7:20:2, X7:15:2, Y7:15:15);
   Print("Good:", "    1234567890123456.78","     1234567890.00","              0.123456780000000");   
   Print("");
   Print("Calc:", V8:20:2, X8:15:2, Y8:15:15);
   Print("Good:", "   12345678901234567.89","    12345678901.00","              0.234567800000000");   
   Print("");
   Print("Calc:", V9:20:2, X9:15:2, Y9:15:15);
   Print("Good:", "  100000000000000008.00","   100000000000.00","              0.000008009000000");   
   Print("");
end;