Page 1 of 1

Value overflow in TChartAxis.CalcIncrement

Posted: Tue Sep 02, 2008 8:56 am
by 9343260
Hello,

I have a problem with a new portion of code in TeEngine.pas : TChartAxis.CalcIncrement().

Code: Select all

tmpMin:=Increment*Round(IMinimum);
We have very high values, like 1e24, and if you make :

increment * iminimum
i.e. 1e20 * 1e24 => the Double range is overflowed


For the moment, we removed this calculation and put back the old version we had and which works :

Code: Select all

tmpMid:=(IMinimum+IMaximum)*0.5;

What about using Extended, would it be possible ?

Posted: Tue Sep 02, 2008 9:22 am
by narcis
Hi bertrod,

Thanks for reporting. I've added your request to the wish-list to be considered for inclusion in next releases.

Posted: Wed Sep 03, 2008 9:29 am
by narcis
Hi bertrod,

As an update, we think the problem is in the Round method which crashes even using Extended with "large" values, for example:

Code: Select all

var tmp : Extended;
  tmp:=1e18;
  tmp:=Round(tmp);   // <--- OK

  tmp:=1e1800001;
  tmp:=Round(tmp);   // <--- floating point overflow exception
In that case, the solution is not changing to Extended nor changing the code to how it was before because customers who are happy with this would complain.

To avoid this exception, a solution could be setting RoundFirstLabel := False so that code doesn't use Round method.