Pascal with braces

Delphi code posted by solo12zw74
created at 03 Sep 07:11

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function MathRound(input : double; deg: byte) : extended;
var
mult: extended;
prelastdigit : byte;
tTmp, tmpResult : Int64;
begin
  tTmp := Trunc(input * Power(10,deg+1));

  prelastdigit :=  tTmp Mod 10;
  mult := Power(10,deg);
  if (prelastdigit < 5) then
    tmpResult := Trunc(input*mult)
  else
    tmpResult := Trunc(input*mult) + 1;
  Result := tmpResult / mult;
end;
390 Bytes in 2 ms with coderay