-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmaths.pas
More file actions
42 lines (34 loc) · 696 Bytes
/
maths.pas
File metadata and controls
42 lines (34 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
unit maths;
interface
function Max(const A, B: Integer): Integer;
function Min(const A, B: Integer): Integer;
function Ceil(const X: Extended): Integer;
function Floor(const X: Extended): Integer;
implementation
function Min(const A, B: Integer): Integer;
begin
if A < B then
Result := A
else
Result := B;
end;
function Max(const A, B: Integer): Integer;
begin
if A > B then
Result := A
else
Result := B;
end;
function Ceil(const X: Extended): Integer;
begin
Result := Integer(Trunc(X));
if Frac(X) > 0 then
Inc(Result);
end;
function Floor(const X: Extended): Integer;
begin
Result := Integer(Trunc(X));
if Frac(X) < 0 then
Dec(Result);
end;
end.