Power of 10 in java
I am looking a function that can do power of 10. Example: 10 to power of 0 is 1, 10 to the power of 1 is 10, 10 to the power of 2 is 100. etc.
Math.pow(a,b) will compute a^b
Thanks for the answer above.
I have one more question, I am looking the logic to solve the following question.
I have an array containing N digits of integer. I'd like to swapping those integer around. For example: 12345. becomes: 12354, 12534, 15234 and so on.
Do you want the swapping to follow any particular rules?
Basically what I am trying to do is swap it and then compare to the orginal set to see if it is greater than. if not, keep swapping until it's greater than the orginal.
For example: 12345 to 12354. so 12354 is > then 12345.
The simplest way to shuffle digits is to convert the number to a byte array, then shuffle this array, and convert the shuffled byte array back to an int.
// convert int to byte array
byte  bb=Integer.toString(newInt).getBytes();
// shuffle the bytes
// convert byte array to int
int newInt=Integer.parseInt(new String(b));
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center