add some rudimentary math functions
This commit is contained in:
@ -1,11 +0,0 @@
|
|||||||
#ifndef __MATH_INCLUDE_H_
|
|
||||||
#define __MATH_INCLUDE_H_
|
|
||||||
|
|
||||||
// NOTE: I added this file
|
|
||||||
|
|
||||||
int min(int, int);
|
|
||||||
int max(int, int);
|
|
||||||
int abs(int);
|
|
||||||
int pow(int, unsigned int);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
10
c_os/lib/Math.cc → c_os/lib/MyMath.cc
Normal file → Executable file
10
c_os/lib/Math.cc → c_os/lib/MyMath.cc
Normal file → Executable file
@ -1,23 +1,23 @@
|
|||||||
#include "Math.h"
|
#include "MyMath.h"
|
||||||
|
|
||||||
// NOTE: I added this file
|
// NOTE: I added this file
|
||||||
|
|
||||||
int min(int a, int b) {
|
int mymin(int a, int b) {
|
||||||
if (a < b) { return a; }
|
if (a < b) { return a; }
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
int max(int a, int b) {
|
int mymax(int a, int b) {
|
||||||
if (a < b) { return b; }
|
if (a < b) { return b; }
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int abs(int a) {
|
int myabs(int a) {
|
||||||
if (a < 0) { return -a; }
|
if (a < 0) { return -a; }
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pow(int a, unsigned int b) {
|
int mypow(int a, unsigned int b) {
|
||||||
int result = 1;
|
int result = 1;
|
||||||
for (unsigned int i = 0; i < b; ++i) {
|
for (unsigned int i = 0; i < b; ++i) {
|
||||||
result = result * a;
|
result = result * a;
|
||||||
12
c_os/lib/MyMath.h
Executable file
12
c_os/lib/MyMath.h
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __MYMATH_INCLUDE_H_
|
||||||
|
#define __MYMATH_INCLUDE_H_
|
||||||
|
|
||||||
|
// NOTE: I added this file
|
||||||
|
|
||||||
|
// TODO: namespace this
|
||||||
|
int mymin(int, int);
|
||||||
|
int mymax(int, int);
|
||||||
|
int myabs(int);
|
||||||
|
int mypow(int, unsigned int);
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user