-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMathLib.h
77 lines (52 loc) · 1.02 KB
/
MathLib.h
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
#ifndef MATHLIB
#define MATHLIB
#include <string>
/*
return the absolute value of the int
*/
int absVal(int num);
/*
reutrn the absolute value of the long
*/
long absVal(long num);
/*
return the absolute value of the double.
*/
double absVal(double num);
/*
return the ceiling of the double
*/
long ceiling (double num);
/*
return the floor of the double
*/
long floor (double num);
enum RoundingRule {
ROUND_HALF_UP,
ROUND_DOWN,
ROUND_UP,
ROUND_TO_ZERO,
ROUND_AWAY_ZERO,
ROUND_HALF_DOWN,
ROUND_HALF_TO_ZERO,
ROUND_HALF_AWAY_ZERO,
ROUND_HALF_TO_ODD,
ROUND_HALF_TO_EVEN,
};
/*
return rounded value according to the rounding rule
*/
long round(double num, RoundingRule rule);
/*
Raise the double by the long value
*/
double pow (double num, long exponent);
/*
build a string representation of the int using the unsigned int by the radix
*/
std::string toString (int num, unsigned int radix, bool lower);
/*
Return the greatest common divisor of the two parameters
*/
int gcd (int num1, int num2);
#endif