SayoriOS 0.3.3

modf.c
1 #include "lib/math.h"
2
3 double modf(double value, double* intPart) {
4 if (intPart != NULL) {
5 *intPart = (value >= 0) ? floor(value) : ceil(value);
6 return value - (*intPart);
7 }
8 return 0.0f;
9 }
10
11 double fmod(double dividend, double divisor) {
12 if (divisor == 0) {
13 return 0.0;
14 }
15
16 double quotient = dividend / divisor;
17 int intPart = (int) quotient; // Integer part
18 double fractionalPart = quotient - intPart; // Fractional part
19
20 double result = fractionalPart * divisor;
21 return result;
22 }