Login Page - Create Account

Support Board


Date/Time: Wed, 15 Jan 2025 11:53:21 +0000



Post From: Question About Float Precision in Sierra Chart API(ACSIL)

[2024-08-13 20:36:59]
User856649 - Posts: 5

These functions are availble for comparison of floating point values.

sc.FormattedEvaluate()
sc.FormattedEvaluateUsingDoubles()
thanks for the info. these functions are the alternative ways to compare two binary floating-point number. however, the inaccuracy is not limited to the comparison, but also on the storage. a simple example, as following:

i define two binary floating-point numbers:
float fnumber = 10.12;
double dnumber = 10.12;

in memory showed by debug window, they look like below:
fnumber is 10.1199999
dnumber is 10.119999999999999

and as far as i know, the internal arrays in SC are either float or double, such as sc.Subgraph[].Data[] / sc.Subgraph[][] (Read/Write. Array of float variables (SCFloatArray)).
maybe for most cases, this inaccuracy will not cause any issue, but for some cases, it causes issues (sometimes the issue will be unpredictable). that is why i bring this topic out for discussion.
I'll take a wild guess that when SC was first being developed (1996), the authors probably didn't realize that using binary floating-point numbers could cause issues, or at that time, the whole finance industry hadn't really come to a consensus on using decimal floating-point numbers. So, it would be good for SC support/engineering to share their thoughts on this problem.

thanks.