I'm writing something to help my daughter with maths and came across a little problem which I solved, but wondered if there was a neater way of doing it? More out of interest than anything.
Essentially I have a two digit number and want to extract what the two digits are to be able to do something with them. So for example if I had the number 59, the first digit would be 5 and the second would be 9.
The way I have done it is to convert it to a string and then split the string and then convert it back to a number again.
Hardly computationally intensive but just seems inefficient. Is there a better/ neater/ shorter way of doing it?
Solved! Go to Solution.
This is my implementation for a general one, seems to work for digits before decimal and after:
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
Great, thank you both! Have given Kudos to both, but selected FireFist-Redhaw