forked from simsum/oscat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMP.EXP
More file actions
executable file
·44 lines (34 loc) · 784 Bytes
/
CMP.EXP
File metadata and controls
executable file
·44 lines (34 loc) · 784 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
43
44
(* @NESTEDCOMMENTS := 'Yes' *)
(* @PATH := '\/Mathematical' *)
(* @OBJECTFLAGS := '0, 8' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION CMP : BOOL
VAR_INPUT
X,Y : REAL;
N : INT;
END_VAR
VAR
tmp : REAL;
END_VAR
(*
version 1.1 10. mar. 2009
programmer hugo
tested by tobias
this function checks two inputs x and y if they are identical with the first N digits
example : cmp(3.141516,3.141517,6 is true.
*)
(* @END_DECLARATION := '0' *)
tmp := ABS(x);
IF tmp > 0.0 THEN
tmp := EXP10(INT_TO_REAL(FLOOR(LOG(tmp))-N+1));
ELSE
tmp := EXP10(tmp);
END_IF;
CMP := ABS(X - Y) < tmp;
(* revision history
hm 12. mar. 2008 rev 1.0
original version
hm 10. mar. 2009 rev 1.1
added type conversion for compatibility reasons
*)
END_FUNCTION