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

RE: Precision Errors - Part 1



PureBytes Links

Trading Reference Links

These messages seems to have gotten blocked by the size limit. I will break them into pieces and see it they go through.
 
Bob Fulks

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