Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = "10"
- local function ToInteger(number)
- return math.floor(tonumber(number) or error("Could not cast '" .. tostring(number) .. "' to number.'"))
- end
- local a = "10"
- print(type(a))
- local num = tonumber(a)
- print(type(num))
- string
- number
- a=tonumber(S)
- a + 0 -- forces the conversion into float, due to how + works
- a | 0 -- (| is the bitwise or) forces the conversion into integer.
- --However, unlike math.tonteger, it errors if it fails
- x = tonumber("10")
- local stringnumber = "10"
- local a = tonumber(stringnumber)
- print(a + 10)
- output:
- 20
- local stringnumber = "10"
- local intnumber = stringnumber * 1
Add Comment
Please, Sign In to add comment