Skip to content
CryoEagle edited this page Dec 26, 2018 · 7 revisions

real

Transforms a string into a real number.

Syntax

real(str, evaluate = false)
Argument Description
string str String to be converted
bool evaluate If set to true, mathematical parser will be applied

Returns: double

Description

This function is used to change a string into a real number. With evaluate set to false this will simply try to parse str to a double and return it. In case of failure (a string with nondigit characters is provided), this will fail and return Double.Nan. When evaluate is set to true, lexical parser will try to eval expression, falling to Double.Nan.

Example

double val = real("5");

Sets the variable val to 5.

Example 2

double val = real("2 + 8 + 12 * (4 - 3)", true); // returns 22 

If we didn't set the second argument to true, this would return Double.Nan instead.

Back to strings

Clone this wiki locally