strtof - ryzom/ryzomcore GitHub Wiki


title: String to Float description: published: true date: 2023-03-12T12:43:46.465Z tags: editor: markdown dateCreated: 2023-03-12T11:52:01.201Z

strtof

The strtof native AI script function is used to convert a string to a float. There are three different versions of this function available, depending on the desired output values.

Syntax

(value: f)strtof(string: s) // strtof_s_f
(value: f, isfloat: f)strtof(string: s) // strtof_s_ff
(value: f, isfloat: f, isfull: f)strtof(string: s) // strtof_s_fff

Arguments

  • string (string): The string to convert.

Return values

The return values of the strtof function depend on which version of the function is used:

(f)strtof(s)

  • value (float): The converted value of the string.

(f, f)strtof(s)

  • value (float): The converted value of the string.
  • isfloat (float): A boolean value indicating whether the input string contained a value (1) or not (0).

(f, f, f)strtof(s)

  • value (float): The converted value of the string.
  • isfloat (float): A boolean value indicating whether the input string contained a value (1) or not (0).
  • isfull (float): A boolean value indicating whether the input string only contained the converted value (1) or not (0).

Examples

(val)strtof($str);

This example code calls the strtof function with a string variable $str and returns the converted value as a float.

(val, isfloat)strtof($str);

This example code calls the strtof function with a string variable $str and returns the converted value as a float, as well as a boolean indicating whether the input string contained a value.

(val, isfloat, isfull)strtof($str);

This example code calls the strtof function with a string variable $str and returns the converted value as a float, as well as two booleans indicating whether the input string contained a value and whether it only contained the converted value.

⚠️ **GitHub.com Fallback** ⚠️