@@ -84,6 +84,8 @@ TWSThread = class(TWSThreadBase)
8484
8585 TWSThreadsWatcher = class (TWSThreadBase)
8686 private
87+ function RoundEx (x: Double): Double;
88+ function PascalRound (x: Double): Double;
8789 procedure CreateFinalList ;
8890 protected
8991 procedure Execute ; override;
@@ -493,6 +495,32 @@ function Compare(List: TStringList; Index1, Index2: Integer): Integer;
493495 end ;
494496end ;
495497
498+ function TWSThreadsWatcher.RoundEx (x: Double): Double;
499+ begin
500+ Result := PascalRound(x*10.0 )/10.0 ;
501+ end ;
502+
503+ function TWSThreadsWatcher.PascalRound (x: Double): Double;
504+ var
505+ t: Double;
506+ begin
507+ // round towards positive infinity
508+ t := Trunc(x);
509+ if (x < 0.0 ) and (t - x = 0.5 ) then
510+ begin
511+ // Do nothing
512+ end
513+ else if Abs(x - t) >= 0.5 then
514+ begin
515+ t := t + Math.Sign(x);
516+ end ;
517+
518+ if t = 0.0 then
519+ Result := 0.0
520+ else
521+ Result := t;
522+ end ;
523+
496524procedure TWSThreadsWatcher.CreateFinalList ;
497525var
498526 I: Integer;
@@ -516,9 +544,9 @@ procedure TWSThreadsWatcher.CreateFinalList;
516544 Continue;
517545 SetString(Name , Pointer(@WS.FStation[0 ]), Length(WS.FStation));
518546 SetCodePage(Name , CP_UTF8, True);
519- Min := WS.FData.FMin/10 ;
520- Max := WS.FData.FMax/10 ;
521- Mean := WS.FData.FTot/WS.FData.FCnt/10 ;
547+ Min := RoundEx( WS.FData.FMin/10 ) ;
548+ Max := RoundEx( WS.FData.FMax/10 ) ;
549+ Mean := RoundEx( WS.FData.FTot/WS.FData.FCnt/10 ) ;
522550 Str := Name + ' =' + FormatFloat(' 0.0' , Min) + ' /' + FormatFloat(' 0.0' , Mean) + ' /' + FormatFloat(' 0.0' , Max) + ' ,' ;
523551 SL.Add(Str);
524552 end ;
0 commit comments