-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMATH.PAS
89 lines (74 loc) · 1.83 KB
/
MATH.PAS
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
Math Unit
All things about numbers
2022 LRT
}
unit
math;
interface
function pow(value, exp: byte): longint;
function maxword(a, b:word): word;
function minword(a, b:word): word;
function maxint(a, b:integer): integer;
function minint(a, b:integer): integer;
function maxlong(a, b:longint): longint;
function minlong(a, b:longint): longint;
function loword(l: longint): word;
function hiword(l: longint): word;
procedure swapint(var first, second : integer);
function incptr(p: pointer; count: word): pointer;
implementation
function pow(value, exp: byte): longint;
var
res: longint;
i: byte;
begin
res := 1;
for i := 1 to exp do res := res * value;
pow := res;
end;
function maxword(a, b:word): word;
begin
if a>b then maxword := a else maxword := b;
end;
function minword(a, b:word): word;
begin
if a<b then minword := a else minword := b;
end;
function maxint(a, b:integer): integer;
begin
if a>b then maxint := a else maxint := b;
end;
function minint(a, b:integer): integer;
begin
if a<b then minint := a else minint := b;
end;
function maxlong(a, b:longint): longint;
begin
if a>b then maxlong := a else maxlong := b;
end;
function minlong(a, b:longint): longint;
begin
if a<b then minlong := a else minlong := b;
end;
function loword(l: longint): word;
begin
loword := l and $0000FFFF;
end;
function hiword(l: longint): word;
begin
hiword := l shr 16;
end;
procedure swapint(var first, second : integer);
var
temp : Integer;
begin
temp := first;
first := Second;
second := temp;
end;
function incptr(p: pointer; count: word): pointer;
begin
incptr := ptr(seg(p^), ofs(p^) + count);
end;
end.