-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.str
More file actions
93 lines (88 loc) · 1.14 KB
/
math.str
File metadata and controls
93 lines (88 loc) · 1.14 KB
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
90
91
92
93
namespace Math
{
function Add($a, $b)
{
proc_Add($a,$b);
return *0;
}
function Sub($a, $b)
{
proc_Sub($a,$b);
return *0;
}
function Div($a,$b)
{
proc_Div($a,$b);
return *0;
}
function Mul($a,$b)
{
proc_Mul($a,$b);
return *0;
}
//This does not work
function Fac($a)
{
$r = new(1);
if($a > 0)
{
$b = get($a);
$loop = new(true);
While($Loop){
$r = Mul($r,$b);
$b = Sub($b,1);
if($b < 1)
{
$loop = new(false);
}
}
}
//This does not work
function Pow($a,$b)
{
$r = new(1);
if($a > 0)
{
$loop = new(true);
While($Loop){
$r = Mul($r,$a);
$b = Sub($b,1);
if($b > 0)
{
$loop = new(false);
}
}
}
return $r;
}
function Abs($a)
{
$r = new($a);
if($r < 0)
{
$r = Mul($r,-1);
}
return $r;
}
function Pi()
{
// note this is not true PI
// cant be an Integer???
$pi = new("3.1415926535897932384626433832795");
return $pi;
}
function E()
{
// note this is not true Euler's number
// cant be an Integer???
$e = new("2.7182818284590452353602874713527");
return $e;
}
function Write(*1)
{
*2 = new(1);
int(1);
int(2);
clear(*2);
}
}