Author |
Message |
Naveg
|
Posted: Fri Sep 15, 2006 11:22 pm Post subject: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
wtd
|
Posted: Sat Sep 16, 2006 8:24 am Post subject: (No subject) |
|
|
I don't believe this is a part of the library. |
|
|
|
|
![](images/spacer.gif) |
r.3volved
|
Posted: Sat Sep 16, 2006 11:13 am Post subject: (No subject) |
|
|
no it doesn't
this was talked about just the other day here in another thread...
use modulus to pick out each integer |
|
|
|
|
![](images/spacer.gif) |
Naveg
|
Posted: Sat Sep 16, 2006 5:14 pm Post subject: (No subject) |
|
|
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. |
|
|
|
|
![](images/spacer.gif) |
r.3volved
|
Posted: Sat Sep 16, 2006 5:56 pm Post subject: (No subject) |
|
|
just make yourself an extended class and keep it around to include where you need it...
thats what oop is all about |
|
|
|
|
![](images/spacer.gif) |
bugzpodder
![](http://www.vbforums.com/avatar.php?userid=31755&dateline=1038631511)
|
Posted: Sat Sep 16, 2006 8:08 pm Post subject: (No subject) |
|
|
Integer.parseInt(myInteger).charAt(i) |
|
|
|
|
![](images/spacer.gif) |
bugzpodder
![](http://www.vbforums.com/avatar.php?userid=31755&dateline=1038631511)
|
Posted: Sat Sep 16, 2006 8:09 pm Post subject: (No subject) |
|
|
return (myInteger/Math.pow(10,i))%10 |
|
|
|
|
![](images/spacer.gif) |
|