Lipi Reference Lipi

Functions

str.tonumber()

Reads a number out of a string. The result is a float in every form, so a string holding a whole number still comes back as a float.

Syntax · 1 of 4

                str.tonumber(const string source) → const float
              

Arguments

source required const string the string to read a number from

Return Type

const float

Syntax · 2 of 4

                str.tonumber(input string source) → input float
              

Arguments

source required input string the string to read a number from

Return Type

input float

Syntax · 3 of 4

                str.tonumber(simple string source) → simple float
              

Arguments

source required simple string the string to read a number from

Return Type

simple float

Syntax · 4 of 4

                str.tonumber(series string source) → series float
              

Arguments

source required series string the string to read a number from

Return Type

series float

Example


          indicator("String to Number Example", overlay=false)
numStr1 = "123.45"
numStr2 = "456"
num1 = str.tonumber(numStr1)
num2 = str.tonumber(numStr2)
plot(num1, title="Converted Number 1")
plot(num2, title="Converted Number 2")