strtof: Add strtof() as simply a compy of strtod with types and limits changed

This commit is contained in:
Gregory Nutt 2016-10-20 12:07:12 -06:00
parent 2dbcdd781c
commit 30ab01b1d8
3 changed files with 6 additions and 12 deletions

View File

@ -80,18 +80,11 @@
# define environ get_environ_ptr()
#endif
/* The functions strtof() and strtold() are not currently implemented in
* NuttX. Ideally, custom implementations of these functions would be
* provided because:
*
* strtof() - Some MCUs, such as the Cortex-M4F, have built in 32-bit FPU.
* A true implementation could exploit the improved performance by the
* the FPU.
* strtold() - Of course, there is a loss of 32-bits of accuracy in this
* conversion.
/* The function strtold() is not currently implemented in NuttX. Ideally, a
* custom implementation should be provided because, of course, there is a
* loss of 32-bits of accuracy in this conversion.
*/
#define strtof(a,b) (float)strtod(a,b)
#define strtold(a,b) (long double)strtod(a,b)
/****************************************************************************
@ -205,6 +198,7 @@ unsigned long long strtoull(FAR const char *nptr, FAR char **endptr,
int base);
#endif
double_t strtod(FAR const char *str, FAR char **endptr);
float strtof(FAR const char *str, FAR char **endptr);
#define atoi(nptr) ((int)strtol((nptr), NULL, 10))
#define atol(nptr) strtol((nptr), NULL, 10)

View File

@ -39,7 +39,7 @@ CSRCS += lib_abs.c lib_abort.c lib_div.c lib_ldiv.c lib_lldiv.c
CSRCS += lib_imaxabs.c lib_itoa.c lib_labs.c lib_llabs.c
CSRCS += lib_bsearch.c lib_rand.c lib_qsort.c lib_srand.c
CSRCS += lib_strtol.c lib_strtoll.c lib_strtoul.c lib_strtoull.c
CSRCS += lib_strtod.c lib_checkbase.c
CSRCS += lib_strtod.c lib_strtof.c lib_checkbase.c
ifeq ($(CONFIG_FS_WRITABLE),y)
CSRCS += lib_mktemp.c lib_mkstemp.c

View File

@ -92,7 +92,7 @@ double_t strtod(FAR const char *str, FAR char **endptr)
double_t number;
int exponent;
int negative;
char *p = (char *) str;
FAR char *p = (FAR char *) str;
double p10;
int n;
int num_digits;