split a number into its digits
An other way could be, if your number has no decimals, to divide
recursively the number by 10, and then assign to an array variable the
difference multiplied by 10 of the divided number and its integer
part.
An example, that's clearer:
number= 2345
numb_by_10= 2345/10= 234.5
int_numb_by_10= 234
diff= 234.5 - 234= .5
10xdiff= 10*.5= 5 -------------------------- first element of the
array variable.
And so forth.
|