Skip to content

Commit daf2758

Browse files
committed
chore: DCornelius:Baseline.Common.RoundExDouble
1 parent 0b48533 commit daf2758

4 files changed

Lines changed: 17 additions & 21 deletions

File tree

baseline/Common/baseline.common.pas

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
interface
88

99
uses
10-
Classes
11-
, SysUtils
10+
System.SysUtils
1211
;
1312

1413
function RoundExDouble(const ATemp: Double): Double;

entries/dcornelius/src/dcornelius.dproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@
8686
<CfgParent>Base</CfgParent>
8787
<Base>true</Base>
8888
</PropertyGroup>
89+
<PropertyGroup Condition="('$(Platform)'=='Linux64' and '$(Cfg_2)'=='true') or '$(Cfg_2_Linux64)'!=''">
90+
<Cfg_2_Linux64>true</Cfg_2_Linux64>
91+
<CfgParent>Cfg_2</CfgParent>
92+
<Cfg_2>true</Cfg_2>
93+
<Base>true</Base>
94+
</PropertyGroup>
8995
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
9096
<Cfg_2_Win32>true</Cfg_2_Win32>
9197
<CfgParent>Cfg_2</CfgParent>
@@ -240,11 +246,16 @@
240246
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
241247
<DCC_DebugInformation>0</DCC_DebugInformation>
242248
</PropertyGroup>
249+
<PropertyGroup Condition="'$(Cfg_2_Linux64)'!=''">
250+
<DCC_UnitSearchPath>..\..\..\baseline\Common;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
251+
</PropertyGroup>
243252
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
244253
<VerInfo_Locale>1033</VerInfo_Locale>
254+
<DCC_UnitSearchPath>..\..\..\baseline\Common;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
245255
</PropertyGroup>
246256
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
247257
<VerInfo_Locale>1033</VerInfo_Locale>
258+
<DCC_UnitSearchPath>..\..\..\baseline\Common;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
248259
</PropertyGroup>
249260
<ItemGroup>
250261
<DelphiCompile Include="$(MainSource)">

entries/dcornelius/src/uChallengeCommon.pas

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ TChallengeCommon = class
3333
public
3434
constructor Create(const NewInputFilename: string);
3535
procedure ReadAndParseAllData(WeatherCityProcessor: TWeatherCityProc);
36-
function PascalRound(x: Double): Double;
3736
function SplitCityTemp(const StationLine: string; var CityName: string; var CityTemp: Integer): Boolean;
3837
property InputFilename: string read FInputFilename write FInputFilename;
3938
end;
@@ -48,7 +47,8 @@ implementation
4847
{$IFDEF DEBUG}
4948
System.Diagnostics,
5049
{$ENDIF }
51-
System.Math;
50+
System.Math,
51+
Baseline.Common;
5252

5353
{ TChallengeCommon }
5454

@@ -62,20 +62,6 @@ constructor TChallengeCommon.Create(const NewInputFilename: string);
6262
raise EFileNotFoundException.Create(NewInputFilename + ' not found.');
6363
end;
6464

65-
function TChallengeCommon.PascalRound(x: Double): Double;
66-
var
67-
t: Double;
68-
begin
69-
// round towards positive infinity
70-
t := Trunc(x);
71-
if (x < 0.0) and (t - x = 0.5) then
72-
Result := t
73-
else if Abs(x - t) >= 0.5 then
74-
Result := t + Sign(x)
75-
else
76-
Result := x;
77-
end;
78-
7965
procedure TChallengeCommon.ReadAndParseAllData(WeatherCityProcessor: TWeatherCityProc);
8066
var
8167
StreamReader: TStreamReader;
@@ -166,7 +152,7 @@ constructor TWeatherCity.Create(const NewCityName: string; const NewTemp: Intege
166152

167153
function TWeatherCity.Mean: Double;
168154
begin
169-
Result := ChallengeCommon.PascalRound(TotalTemp / DataCount);
155+
Result := RoundExDouble(TotalTemp / DataCount);
170156
end;
171157

172158
function TWeatherCity.OutputSumLine: string;

entries/dcornelius/src/udmChallengeWithFireDAC.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface
1818
FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
1919
FireDAC.Stan.ExprFuncs, FireDAC.Phys.SQLiteWrapper.Stat, FireDAC.Phys.SQLiteDef, FireDAC.UI.Intf, FireDAC.Stan.Def,
2020
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite, FireDAC.ConsoleUI.Wait,
21-
FireDAC.Phys.SQLiteVDataSet, FireDAC.DApt;
21+
FireDAC.Phys.SQLiteVDataSet, FireDAC.DApt, Baseline.Common;
2222

2323
type
2424
TdmChallengeWithFireDAC = class(TDataModule)
@@ -55,7 +55,7 @@ procedure ChallengeWithFireDAC;
5555

5656
function OutputLine: string;
5757
begin
58-
var MeanTemp := ChallengeCommon.PascalRound(dmChallengeWithFireDAC.qryCityTempsSumTemp.AsFloat /
58+
var MeanTemp := RoundExDouble(dmChallengeWithFireDAC.qryCityTempsSumTemp.AsFloat /
5959
dmChallengeWithFireDAC.qryCityTempsTempCount.AsFloat);
6060
Result := Format('%s=%0.1f/%0.1f/%0.1f',
6161
[dmChallengeWithFireDAC.qryCityTempsCityName.AsString,

0 commit comments

Comments
 (0)