meta: move photon/libc to root

This commit is contained in:
2026-02-08 20:45:25 +00:00
parent f00e74260d
commit 345a37962e
140 changed files with 0 additions and 0 deletions

33
libc/stdlib/strtof.c Normal file
View File

@@ -0,0 +1,33 @@
#include <ctype.h>
float strtof(const char *str, char **endptr)
{
float res = 0.0F;
char *ptr = (char*)str;
int after_dot = 0;
float div = 1;
while (*ptr != '\0') {
if (isdigit(*ptr)) {
if (!after_dot) {
res *= 10;
res += *ptr - '0';
} else {
div *= 10;
res += (float)(*ptr - '0') / div;
}
} else if (*ptr == '.') {
after_dot = 1;
} else {
break;
}
ptr++;
}
if (endptr) {
*endptr = ptr;
}
return res;
}