@@ -70,45 +70,11 @@ Submit your implementation and become part of the leader board!
7070
7171## Rounding
7272
73- In a discussion with [ Mr. Packman] ( https://pack.ac/ ) themselves, we came up with a simpler solution. They even added some _ Unit Testing_ : D .
74-
75- This will be the official way to round the output values, so pick your poison:
76- ``` pas
77- function RoundEx(x: Currency): Double; inline;
78- begin
79- Result := Ceil(x * 10) / 10;
80- end;
81-
82- function RoundExInteger(x: Currency): Integer; inline;
83- begin
84- Result := Ceil(x * 10);
85- end;
86-
87- { Neater version by @bytebites from Lazarus forum }
88- function RoundExString(x: Currency): String; inline;
89- var
90- V, Q, R: Integer;
91- begin
92- V := RoundExInteger(x);
93- divmod(V, 10, Q, R);
94- Result := IntToStr(Q) + '.' + chr(48 + Abs(R))
95- end;
96-
97- procedure Test;
98- var
99- F: Double;
100- begin
101- for F in [10.01, 10.04, -10.01, -10.0, 0, -0, -0.01] do
102- WriteLn(RoundExInteger(F), ' ', RoundExString(F), ' ', RoundEx(F));
103- //101 10.1 1.0100000000000000E+001
104- //101 10.1 1.0100000000000000E+001
105- //-100 -10.0 -1.0000000000000000E+001
106- //-100 -10.0 -1.0000000000000000E+001
107- //0 0.0 0.0000000000000000E+000
108- //0 0.0 0.0000000000000000E+000
109- //0 0.0 0.0000000000000000E+000
110- end;
111- ```
73+ With the help of this magnificent community, we were able to finally get to a rounding solution that works.
74+
75+ This means that I'm encouraging everyone to use the code that is now in the [ Baseline.Commom] ( baseline/Common ) unit.\
76+ I do have to make crystal clear that using that code is an ** option** , one that you can always opt out of.\
77+ But if you do opt in, just include that unit in your entry and job's a done.
11278
11379## Generating the measurements.txt
11480> ** NOTE**
0 commit comments