
-----------------------------------
Naveg
Fri Sep 15, 2006 11:22 pm

Method for breaking a number into its digits
-----------------------------------
Does java have a method that will do this? I can easily code this myself, but I was wondering if it was already a part of the java library. Essentially you pass a number to the method and it returns an array of ints consisting of the individual digits.

-----------------------------------
wtd
Sat Sep 16, 2006 8:24 am


-----------------------------------
I don't believe this is a part of the library.

-----------------------------------
r.3volved
Sat Sep 16, 2006 11:13 am


-----------------------------------
no it doesn't
this was talked about just the other day here in another thread...

use modulus to pick out each integer

-----------------------------------
Naveg
Sat Sep 16, 2006 5:14 pm


-----------------------------------
yea, i know how to do it - its really easy. Its just that i need to work with digits in many of of my programs, so it would be nice if it were a part of the library.

-----------------------------------
r.3volved
Sat Sep 16, 2006 5:56 pm


-----------------------------------
just make yourself an extended class and keep it around to include where you need it...

thats what oop is all about

-----------------------------------
bugzpodder
Sat Sep 16, 2006 8:08 pm


-----------------------------------
Integer.parseInt(myInteger).charAt(i)

-----------------------------------
bugzpodder
Sat Sep 16, 2006 8:09 pm


-----------------------------------
return (myInteger/Math.pow(10,i))%10
