PureBytes Links
Trading Reference Links
|
-----Message d'origine-----
De : pierre.orphelin [mailto:pierre.orphelin@xxxxxxxxxxxxxx]
Envoye : lundi 23 juillet 2001 21:28
A : Bob Fulks
Cc : OmegaList
Objet : RE: Precision Errors
Bob, I read your post, see your previous test and what I have to say is when
comparing the correct number ( line3 below)
TS4.0: 12345678 here is where it diverges==>
63620.00 -539223040.00 12884901888.000000000000000
TS2000: 12345678 here is where it diverges too==> 407663616.00
12345678848.00 0.000000000000000
Correct: 12345678 901234567.89 12345678901.00
0.234567800000000
TS may display what it wants after digit 8 because it does not use
exponents, but the digits displayed after 8th digit is garbage, as announced
by the theory.
A float being a 32 bits BINARY number, you cannot expect a decimal number
with more than 10 digits ( 2^32), even if the magnitude of the number is
more than this ( magnitude being carried by the exponent part that is coded
in the 32 bit binary number, that in fact reduces the precision mantissa
part ).
So the example provided by Kent is dead wrong becase the precision should
have been carried by the 22th digit, what could even not exist by adding two
doubles !)
My 9999999 limit in the average_WC test was beyond this limit to avoid to
have a part of the higher number carried by the exponent at the detriment of
the mantissa.
>From your other examples, it appears that the 7 digits is the limit of TS
precision, what is correct with what I say and I have nothing more to add...
Sincerely,
Pierre Orphelin
www.sirtrade.com
TradeStation Technologies representative in France
-----Message d'origine-----
De : Bob Fulks [mailto:bfulks@xxxxxxxxxxxx]
Envoye : lundi 23 juillet 2001 21:01
A : pierre.orphelin@xxxxxxxxxxxxxx
Cc : OmegaList
Objet : RE: Precision Errors
At 1:30 AM +0200 7/23/01, pierre.orphelin wrote:
> The way I read Kent's post he is exactly correct so I conclude that
> he understands how floating point works.
>
Are you kidding?
The number of signifiant digits in FP is no more than 10 ( depends on
various sources), and what I read was an example waiting for a 22 digits
precision by ading two Float, means a perfect misunderstanding!
When Kent said:
For example, if you add 0.000111111111111 to 1,000,000,000 you
might end up with something like 1,000,000,000.1.
he was saying that the low order digits would be incorrect - that a
correct result required 25 digits of precision and that floating
point representation could not properly represent that many digits.
He is correct. You appear to not be understanding his words correctly.
I tested this in TS4.0. It turns out that of you try to add less than
about 100 to 1,000,000,000 you still get 1,000,000,000.00
If you add 100.000111111 to 1,000,000,000 you get
1,000,000,122.0700000 internally in the variable and it prints as
1,000,000,128.00 for some reason. The precision is about 7 decimal
digits as expected.
> The way I read your post of 7/19/01 suggesting the following code:
>
> >if sum> = 9999999- 2*price
> >{ please check the acceptable precision limit according to your own TS
> >precision belief}
> >then begin
>
> makes me think that you do not understand how floating point works.
The 9999999 7 digits limit has been set beyond the FP limit to avoid the TS
problem overflow where the precision may be lost after a given high limit.
As anyone disagree on what is the true TS variable precision, I have set
this " according to your own belief" in my comment.
Please conduct further testing if yoy want to determine what is the highest
number in EL not affected by cumulative overflow, I have other things to do.
The only reproach that yoiu can do is thta I gave the example for a
positive accumulation ( whre in this case you may use the absvalue.
Not correct. TradeStation 4.0 can represent numbers as high as
100,000,000,000,000,008.0090
which is the largest number that the PowerEditor of TS4.0 would let
me specify as a constant.
I did run a test on TS4.0. I assigned various values to variables and
then printed them out in different ways. The results are appended below.
The first column of the printout is a label.
The second column is the number as printed by the Print routine.
I then divided each number by 1,000,000 and calculated the integer
and fractional parts of the result using the functions provided. I
then printed the resulting integer and fractional parts in columns
three and four.
The first row for each value is the calculated values from TS4.0. The
second row for each value is what the value should have been if the
calculation had been perfect with infinite precision so that you can
easily compare the results.
You can see that there are about 7 digits of precision (as expected
from the single-precision floats) and that TS4.0 can represent
numbers as high as:
1,234,567,948,140,544.00
properly. But when it tries to represent number as high as:
12,345,678,407,663,620.00
it goes crazy generating major errors.
So TradeStation 4.0 can represent numbers far beyond "the 9999999
7 digits limit" you stated in your post.
The situation is similar with TS2000i. (See my next post)
>
> So, based upon these post, I would think you are the one who needs to
> do some reading...
Bad thinking , dear Bob.
I don't think so...
Bob Fulks
---------------
Printed results from test:
Calc: 1234567936.00 1234.00
0.567993000000000
Good: 1234567890.12 1234.00
0.567890123456780
Calc: 12345678848.00 12345.00
0.678711000000000
Good: 12345678901.23 12345.00
0.678901234567800
Calc: 123456790528.00 123456.00
0.789063000000000
Good: 123456789012.34 123456.00
0.789012345678000
Calc: 1234567954432.00 1234568.00
0.000000000000000
Good: 1234567890123.45 1234567.00
0.890123456780000
Calc: 12345679020032.00 12345679.00
0.000000000000000
Good: 12345678901234.56 12345678.00
0.901234567800000
Calc: 123456788103168.00 123456792.00
0.000000000000000
Good: 123456789012345.67 123456789.00
0.012345678000000
Calc: 1234567948140544.00 1234567936.00
0.000000000000000
Good: 1234567890123456.78 1234567890.00
0.123456780000000
Calc: 12345678407663620.00 -539223040.00
12884901888.000000000000000
Good: 12345678901234567.89 12345678901.00
0.234567800000000
Calc: 99999998430674940.00 1215750144.00
98784247808.000000000000000
Good: 100000000000000008.00 100000000000.00
0.000008009000000
{ *******************************************************************
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;
|