Skip to content

Commit 13d8dbc

Browse files
committed
docs(README): Official rounding function
1 parent 85bbab1 commit 13d8dbc

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,38 @@ I have a Windows VM, with RAD Studio installed, that will do the necessary cross
6363

6464
Submit your implementation and become part of the leader board!
6565

66+
## Rounding
67+
68+
Székely Balázs has provided code for rounding towards positive infinity per the original challenge.\
69+
This will be the official way to round the output values:
70+
```pas
71+
function TBaseline.RoundEx(x: Double): Double;
72+
begin
73+
Result := PascalRound(x*10.0)/10.0;
74+
end;
75+
76+
function TBaseline.PascalRound(x: Double): Double;
77+
var
78+
t: Double;
79+
begin
80+
//round towards positive infinity
81+
t := Trunc(x);
82+
if (x < 0.0) and (t - x = 0.5) then
83+
begin
84+
// Do nothing
85+
end
86+
else if Abs(x - t) >= 0.5 then
87+
begin
88+
t := t + Math.Sign(x);
89+
end;
90+
91+
if t = 0.0 then
92+
Result := 0.0
93+
else
94+
Result := t;
95+
end;
96+
```
97+
6698
## Generating the measurements.txt
6799
> **NOTE** \
68100
> We now have both a Lazarus version and a Delphi version of the generator for both 32b and 64b.
@@ -105,7 +137,7 @@ Expected `SHA256` hash:
105137

106138
> **NOTE**
107139
>
108-
> I'm still being lazy and I need to do the baseline in order for us to have the same `SHA256` value for an official output.
140+
> We are still waiting for the Delphi version to be completed in order for us to have an official `SHA256` hash for the output.
109141
110142
## Results
111143
These are the results from running all entries into the challenge on my personal computer:

0 commit comments

Comments
 (0)