I need to breakdown a 3 digit number to get each digit's value. I know how to get the first and last digit's values by using the below:
var myInt: Int = 248
print(myInt/100) // first number equals 2
print(myInt%10) // last number equals 8
And I also do know how to get the middle digit's value using the below:
print((myInt - myInt/100*100 - myInt%10)/10) // middle number equals 4
However, I feel that the way I get the middle digit's value is too messy and that there is probably a more simpler way of getting the same result.
Does any know a more simpler option to getting the middle digit's value then what I am currently using?