Everything

strtof


Converts a number-representing string to a float type floating-point number.

[Format]

#include <stdlib.h>

float strtof (const char *nptr, char **endptr);

[Parameters]

nptr Pointer to a number-representing string to be converted

endptr Pointer to the storage area containing a pointer to the first character that does not represent a floating-point number

[Return values]

Normal: If the string pointed by nptr begins with a character that does not represent a floating-point number: 0

If the string pointed by nptr begins with a character that represents a floating-point number: Converted data as a float type floating-point number

Abnormal: If the converted data overflows: HUGE_VALF with the same sign as that of the string before conversion

If the converted data underflows: 0

[Remarks]

If the converted result overflows or underflows, errno is set.

The strtof function converts data, from the first digit or the decimal point up to the character immediately before the character that does not represent a floating-point number, into a float type floating-point number. However, if neither an exponent nor a decimal point is found in the data to be converted, the compiler assumes that the decimal point comes next to the last digit in the string. In the area pointed by endptr, the function sets up a pointer to the first character that does not represent a floating-point number. If some characters that do not represent a floating-point number come before digits, the value of nptr is set. If endptr is NULL, nothing is set in this area.