Add strtof native (bug 5909, r=Nextra)
This commit is contained in:
@ -109,7 +109,7 @@ native str_to_num(const string[]);
|
||||
* @param string The string to parse.
|
||||
* @param endPos The position of the first character following the number.
|
||||
* On success and when containing only numbers, position is at the end of string, meaning equal to 'string' length.
|
||||
* On failure, position is sets always to -1.
|
||||
* On failure, position is sets always to 0.
|
||||
* @param base The numerical base (radix) that determines the valid characters and their interpretation.
|
||||
* If this is 0, the base used is determined by the format in the sequence.
|
||||
* @return On success, the function returns the converted integral number as integer value.
|
||||
@ -117,7 +117,32 @@ native str_to_num(const string[]);
|
||||
* If the value read is out of the range of representable values by a cell,
|
||||
* the function returns 'cellmin' or 'cellmax'.
|
||||
*/
|
||||
native strtol(const string[], &endPos = -1, base = 0);
|
||||
native strtol(const string[], &endPos = 0, base = 0);
|
||||
|
||||
/**
|
||||
* Parses the 'string' interpreting its content as an floating point number and returns its value as a float.
|
||||
* The function also sets the value of 'endPos' to point to the position of the first character after the number.
|
||||
*
|
||||
* This is the same as C++ strtod function with a difference on second param.
|
||||
*
|
||||
* The function first discards as many whitespace characters as necessary until the first
|
||||
* non-whitespace character is found. Then, starting from this character, takes as many
|
||||
* characters as possible that are valid and interprets them as a numerical value.
|
||||
* Finally, a position of the first character following the float representation in 'string'
|
||||
* is stored in 'endPos'.
|
||||
*
|
||||
* If the first sequence of non-whitespace characters in 'string' is not a valid float number
|
||||
* as defined above, or if no such sequence exists because either 'string' is empty or it contains
|
||||
* only whitespace characters, no conversion is performed.
|
||||
*
|
||||
* @param string The string to parse.
|
||||
* @param endPos The position of the first character following the number.
|
||||
* On success and when containing only numbers, position is at the end of string, meaning equal to 'string' length.
|
||||
* On failure, position is sets always to 0.
|
||||
* @return On success, the function returns the converted floating point number as float value.
|
||||
* If no valid conversion could be performed, a zero value is returned.
|
||||
*/
|
||||
native Float:strtof(const string[], &endPos = 0);
|
||||
|
||||
/* Converts float to string. */
|
||||
native float_to_str(Float:fl, string[], len);
|
||||
|
Reference in New Issue
Block a user