Guest User

Untitled

a guest
May 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. a = "10"
  2.  
  3. local function ToInteger(number)
  4. return math.floor(tonumber(number) or error("Could not cast '" .. tostring(number) .. "' to number.'"))
  5. end
  6.  
  7. local a = "10"
  8. print(type(a))
  9. local num = tonumber(a)
  10. print(type(num))
  11.  
  12. string
  13. number
  14.  
  15. a=tonumber(S)
  16.  
  17. a + 0 -- forces the conversion into float, due to how + works
  18.  
  19. a | 0 -- (| is the bitwise or) forces the conversion into integer.
  20. --However, unlike math.tonteger, it errors if it fails
  21.  
  22. x = tonumber("10")
  23.  
  24. local stringnumber = "10"
  25. local a = tonumber(stringnumber)
  26. print(a + 10)
  27.  
  28. output:
  29.  
  30. 20
  31.  
  32. local stringnumber = "10"
  33.  
  34. local intnumber = stringnumber * 1
Add Comment
Please, Sign In to add comment