Takes a string and returns it into a real number.


GML Code Example

real( str );

Argument Description
str The string to be converted to a real value.

Returns: Real


This function can be used to turn a given string into a real number. When using this function, numbers, minus signs, decimal points and exponential parts in the string are taken into account, while other characters (such as letters) will cause an error to be thrown. If you know, or suspect, that a string may have other characters then you can use string_digits() to remove all non-numeric characters, before using this function to turn the resulting string into a real number.


GML Code Example

var t_str;
 t_str = string_digits(input_str);
 age = real(t_str);

The above code will take the input string, strip it of all characters other than numbers and then set the variable "age" to hold the real number value of the return string.

Back: Strings
Next: is_string

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here