0 Members and 2 Guests are viewing this topic.
It seems that the Round and RoundTo functions round down, or take the floor (i think its refered to as that, I don't know), but should round according if it is >= .5 or < .5. A Floor function should round down.Sry if its not called floor, i can't remember off the top of my head.
Function RoundDown(num:Extended) : Integer;begin Result := round(num - 0.4999999);end;
Function RoundUp(num:Extended) : Integer;begin Result := round(num + 0.4999999);end;
Code: [Select]Function RoundDown(num:Extended) : Integer;begin Result := round(num - 0.4999999);end;and similarly...Code: [Select]Function RoundUp(num:Extended) : Integer;begin Result := round(num + 0.4999999);end;
Function RoundDown(num:Extended) : Integer;begin Result := round(num - 0.4999999);end;
Function RoundUp(num:Extended) : Integer;begin Result := round(num + 0.4999999);end;
function RoundDown(num:Extended): Integer;begin Result := round(num); if Result > num then Result := Result - 1;end;
function RoundUp(num:Extended): Integer;begin Result := round(num); if Result < num then Result := Result + 1;end;
Code: [Select]function RoundDown(num:Extended): Integer;begin  Result := round(num);  if Result > num then    Result := Result - 1;end;Code: [Select]function RoundUp(num:Extended): Integer;begin  Result := round(num);  if Result < num then    Result := Result + 1;end;I think this could work.
function RoundDown(num:Extended): Integer;begin  Result := round(num);  if Result > num then    Result := Result - 1;end;
function RoundUp(num:Extended): Integer;begin  Result := round(num);  if Result < num then    Result := Result + 1;end;
strtoint(floattostr(<ExtendedVariableHere>));
function RoundDown(num:Extended): Integer;begin Result := round(num); if StrToFloat(IntToStr(Result)) > num then Result := Result - 1;end;
function RoundUp(num:Extended): Integer;begin Result := round(num); if StrToFloat(IntToStr(Result)) < num then Result := Result + 1;end;