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

Easy Language Math Precision Wrong?



PureBytes Links

Trading Reference Links

Read this old post from the TradeLab list to see.

> >Even though it is possible to print more precise-looking numbers on the
screen, TS4 and TS5 both perform mathematical calculations using what is
called "Single Precision" in Visual Basic.  Easy Language function arguments
are passed as Single Precision values.  Results are returned as Single
Precision values.

James F. Mazzulla asked:

> Thanks for the clarification, Bob. Can you tell us if this is
=particularly= problematic and, if so, what, if any, course of action needs
be taken? TIA

It is not problematic.  It is certain.

There is no reasonable way a user can improve Easy Language mathematical
precision, short of writing high precision mathematical language extensions.
However, Easy Language program code can be designed to reduce end-result
errors due to poor mathematical precision in some cases.  There are several
ways that can be accomplished, depending on the nature of the calculations
being performed.

That is a very big subject books have been written about.  The methods and
related considerations are too extensive to explain here, but you will find
books on the subject in university computer science libraries.  It was an
especially important topic years ago when most computers had poor
mathematical precision, so you might find especially interesting ideas in
books published in the 1960's and 1970's.

  -Bob Brickey
   Scientific Approaches
   sci@xxxxxxxxxx


Chris Baker wrote:

> Besides single precision, TradeStation 4.0 cannot subtract correctly.
>
> Actual example from Easy Language:
> X = LS1 - LS;
>
> Using Print statement:
> LS1 = 868.90000
> LS   = 869.10000
> X = -0.19995100
>
> Since X now has 6 significant digits instead of 1, when I subtracted it
from another variable in the same format as LS and LS1, it lead to a
TradeStation floating point error which required the server to be restarted.

That error is due only to lack of precision.

   -0.2 = 868.90000 - 869.10000

Easy language returned -0.19995100, which is in error by only:

   -.000049 = -0.2 - (-0.19995100)

  -Bob Brickey
   Scientific Approaches
   sci@xxxxxxxxxx