I'm trying to find a way to convert a number into an array of digits, similar to a character array, and still be able to perform mathematical operations on the array.
My first thought was to convert the number to a string, then to a character array, and then convert the array back to Int32 type. However, this has some unexpected results. For example, [int[]](1024).ToString().ToCharArray() results in the following array:
49
48
50
52
I do get what's happening here - PowerShell is treating the digits as ASCII characters, and converting them into their numeric values. However, that doesn't help me solve my problem.
What's the "right way" to convert numbers into single-digit integer arrays?