Howdy! Can you please assist me to safely cast String to Real? I do not know for sure which data will hold the String and get an error, if I pass something inconvertible to Convert String to Real. Which way would be the best for handling this problem?
I have reviewed and actually decided to go just with Integer. I wrote this simple function to check whether a string contains only digits and, therefore, is safely castable to Integer. It doesn't take into consideration some edge cases like min/max sizes for Integer, but is ok for my usecase. You can enchance it to check whether it is convertible to Real just by checking for a single dot (dunno whether dot at the start is acceptable though.
Howdy! Can you please assist me to safely cast String to Real? I do not know for sure which data will hold the String and get an error, if I pass something inconvertible to Convert String to Real. Which way would be the best for handling this problem?
I have reviewed and actually decided to go just with Integer. I wrote this simple function to check whether a string contains only digits and, therefore, is safely castable to Integer. It doesn't take into consideration some edge cases like min/max sizes for Integer, but is ok for my usecase. You can enchance it to check whether it is convertible to Real just by checking for a single dot (dunno whether dot at the start is acceptable though.