From 366a247eab202bb231be224ec33829ce595a434d Mon Sep 17 00:00:00 2001 From: ask Date: Sun, 22 Jan 2012 09:18:07 +0000 Subject: [PATCH] TAChart: Fix various cases of SIGFPE in RoundToImage method git-svn-id: trunk@34853 - --- components/tachart/taintervalsources.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/tachart/taintervalsources.pas b/components/tachart/taintervalsources.pas index 75dbf859bf..07f95cacd0 100644 --- a/components/tachart/taintervalsources.pas +++ b/components/tachart/taintervalsources.pas @@ -282,18 +282,19 @@ procedure TIntervalChartSource.RoundToImage( end; var - i, x: Integer; + i: Integer; v, p, rv: Double; + x: Int64; begin if AParams.FIntervals.Tolerance = 0 then exit; for i := 0 to High(AValues) do begin v := AValues[i].FValue; - if v = 0 then continue; + if (v = 0) or IsInfinite(v) or IsNan(v) then continue; x := A2I(v); p := Power(10, Floor(Log10(Abs(v)) - Log10(High(Int64)) + 1)); - while true do begin + while v <> 0 do begin rv := Round(v / p) * p; - if Cardinal(Abs(A2I(rv) - x)) >= AParams.FIntervals.Tolerance then break; + if Abs(A2I(rv) - x) >= AParams.FIntervals.Tolerance then break; v := rv; p *= 10; end;