I am interested in the question of how to most efficiently split a number (Long.MAX_VALUE
or higher) into its digits and place it in a byte[]
. I used converting a number to a string, and then turned the string into an array with a symbol and wrote it into an array (Pre-subtracting '0'). But I would like to know if there are more effective ways to solve this problem.
Example:
long number = 4644864;
byte[] array = toArray(number);
And in byte[]
array values will be stored in the form [4,6,4,4,8,6,4]