to_number("101", 2) = 5
to_number("101", 10) = 101
The custom function we made today support only whole positive (or null) numbers for now. Since it's the easiest to implement
Stay tunned for the next video were we're gonna support fractional numbers and negative numbers!
Lua does have a tonumber method, which is of course much more faster and convenient than our implementation. But doing stuff the hard way teach you a lot and helps you be grateful of such simple functions XD
Btw programmers in the early days had to do this every time themselves, Nowadays you don't need to implement it yourself unless again you want a custom behavior, like inventing your own number system or ignoring some characters since for example:
tonumber(" 1001 3234") will throw an error because there is a space in there
But keep in mind that there is unlimited amount of solutions for the same problem. that's just my solution, you can come up with your own or even your own numbers :D
Related video(s):
• string.byte and string.char Lua scrip...
Discord server:
/ discord
Support me in paypal:
https://www.paypal.com/paypalme/Codes...
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
Watch video Convert a string into a number the hard way / Lua Scripting online, duration hours minute second in high quality that is uploaded to the channel Codotaku 01 January 1970. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 647 times and liked it 13 visitors.