more math

This commit is contained in:
able 2024-01-09 12:12:33 -06:00
parent 9f168af022
commit b025e301bb
7 changed files with 67 additions and 16 deletions

View file

@ -8,17 +8,17 @@
#include "types/sys_id.h" #include "types/sys_id.h"
#include "types/services.h" #include "types/services.h"
#include "math/math.h"
#include "ecalls.c" #include "ecalls.c"
#include "services/log_service.c" #include "services/log_service.c"
#include "services/csprng_service.c" #include "services/csprng_service.c"
#include "services/memory_service.c" #include "services/memory_service.c"
#include "random/random.c" #include "random/random.c"
#include "arguments.c" #include "arguments.c"
#include "process.c" #include "process.c"
#include "exit.h" #include "exit.h"
#include "collections/vec.c" #include "collections/vec.c"

View file

@ -1,13 +0,0 @@
/*Sadly sometimes dividing people in half is a bad thing actually*/
int divide_up(int n, int d) {
if (n % d == 0) {
return n / d;
}
return 1 + n / d;
}
int square(int a){
return a * a;
} int half(int a){
return a / 2;
}

View file

@ -0,0 +1,28 @@
/*Sadly sometimes dividing people in half is a bad thing actually*/
u8 divide_up_u8(u8 n, u8 d) {
if (n % d == 0) {
return n / d;
}
return 1 + n / d;
}
u16 divide_up_u16(u16 n, u16 d) {
if (n % d == 0) {
return n / d;
}
return 1 + n / d;
}
u32 divide_up_u32(u32 n, u32 d) {
if (n % d == 0) {
return n / d;
}
return 1 + n / d;
}
u64 divide_up_u64(u64 n, u64 d) {
if (n % d == 0) {
return n / d;
}
return 1 + n / d;
}

View file

@ -0,0 +1,15 @@
u8 half_u8(u8 a){
return a / 2;
}
u16 half_u16(u16 a){
return a / 2;
}
u32 half_u32(u32 a){
return a / 2;
}
u64 half_u64(u64 a){
return a / 2;
}

View file

@ -0,0 +1,5 @@
// Math library with various operations on types implemented
#include "square.h"
#include "half.h"
#include "divide_up.h"

View file

@ -0,0 +1,15 @@
u8 square_u8(u8 a){
return a * a;
}
u16 square_u16(u16 a){
return a * a;
}
u32 square_u32(u32 a){
return a * a;
}
u64 square_u64(u64 a){
return a * a;
}

View file

@ -3,7 +3,8 @@
int main() { int main() {
register_exit_code(ecode_new("File System Error")); register_exit_code(ecode_new("File System Error"));
return 1;
return 0;
} }
#include "ableos_std/start.c" #include "ableos_std/start.c"