1

add some rudimentary math functions

This commit is contained in:
churl
2022-05-09 14:03:12 +02:00
parent 5b16da23ed
commit d8d71d712e
3 changed files with 17 additions and 16 deletions

View File

@ -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
View File

@ -1,23 +1,23 @@
#include "Math.h"
#include "MyMath.h"
// NOTE: I added this file
int min(int a, int b) {
int mymin(int a, int b) {
if (a < b) { return a; }
return b;
}
int max(int a, int b) {
int mymax(int a, int b) {
if (a < b) { return b; }
return a;
}
int abs(int a) {
int myabs(int a) {
if (a < 0) { return -a; }
return a;
}
int pow(int a, unsigned int b) {
int mypow(int a, unsigned int b) {
int result = 1;
for (unsigned int i = 0; i < b; ++i) {
result = result * a;

12
c_os/lib/MyMath.h Executable file
View 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