github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/base/lua/tonumber.lua (about) 1 print(tonumber(123)) 2 --> =123 3 4 print(tonumber("321")) 5 --> =321 6 7 print(tonumber("+12")) 8 --> =12 9 10 print(tonumber("-12.45")) 11 --> =-12.45 12 13 print(tonumber("xx")) 14 --> =nil 15 16 print(tonumber("ff", 16)) 17 --> =255 18 19 print(tonumber("-Z", 36)) 20 --> =-35 21 22 print(tonumber(" -1001", 2)) 23 --> =-9 24 25 print(tonumber("012")) 26 --> =12 27 28 print(tonumber("0xffffffffffffffff")) 29 --> =-1 30 31 print(tonumber("-0xffffffffffffffff")) 32 --> =1 33 34 print(tonumber("+102", 3)) 35 --> =11 36 37 print(tonumber("ff", 15)) 38 --> =nil 39 40 print(tonumber("[]", 11)) 41 --> =nil