News for hackers. Stuff that matters.
Re:Tech Companies Want You to Believe America Has a Skills Gap by linuxftw on Wednesday August 05, 2020 @03:40PM (#24064716)
You can detect each digit like this:

For example, take 999 (N). Using only math, how can I determine the value of each digit?

(be sure to take abs(N) and record value of N/abs(N) for later)

res = N - (N - 1). Digit = res + 1; If Digit == 10, Digit = 0.

So, given that function to find each digit, you can build a loop using 10^i to detect each digit (subtracting the sum of all preceding digits and dividing by 10^i to trim the lower order digits you've already resolved).

We'll need a place to store each digit, such as an array.

Of course, this assumes integers in base 10. If they are another base (8, 16), replace the 10^i above with the base.

It's also ambiguous as to if the function should just return a concatenated version of the results or some possibly a sum.

In any case, using a cast to string would be way easier.

Re:Tech Companies Want You to Believe America Has a Skills Gap by quacked on Thursday August 06, 2020 @10:03AM (#24070954)
Thanks!