File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ TChallengeCommon = class
3333 public
3434 constructor Create(const NewInputFilename: string);
3535 procedure ReadAndParseAllData (WeatherCityProcessor: TWeatherCityProc);
36- function PascalRound (x: Double): Double;
36+ function PascalRound (const x: Double): Double;
3737 function SplitCityTemp (const StationLine: string; var CityName: string; var CityTemp: Integer): Boolean;
3838 property InputFilename: string read FInputFilename write FInputFilename;
3939 end ;
@@ -62,18 +62,9 @@ constructor TChallengeCommon.Create(const NewInputFilename: string);
6262 raise EFileNotFoundException.Create(NewInputFilename + ' not found.' );
6363end ;
6464
65- function TChallengeCommon.PascalRound (x: Double): Double;
66- var
67- t: Double;
65+ function TChallengeCommon.PascalRound (const x: Double): Double;
6866begin
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;
67+ Result := Ceil(x * 10 ) / 10 ;
7768end ;
7869
7970procedure TChallengeCommon.ReadAndParseAllData (WeatherCityProcessor: TWeatherCityProc);
You can’t perform that action at this time.
0 commit comments