fxlibc/src/libc/stdlib/strtof.c
Lephenixnoir f5cca84ae8
stdlib: add and test strtod, strtof and atof (DONE)
This uses a generic function strto_fp similar to strto_int that is used
for strtol and its derivatives.
2021-05-21 23:56:35 +02:00

11 lines
213 B
C

#include "stdlib_p.h"
#include <errno.h>
float strtof(char const * restrict ptr, char ** restrict endptr)
{
float f = 0;
int err = strto_fp(ptr, endptr, NULL, &f, NULL);
if(err != 0) errno = err;
return f;
}