Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Method for breaking a number into its digits
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Naveg




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sat Sep 16, 2006 8:24 am   Post subject: (No subject)

I don't believe this is a part of the library.
r.3volved




PostPosted: 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
Naveg




PostPosted: 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.
r.3volved




PostPosted: 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
bugzpodder




PostPosted: Sat Sep 16, 2006 8:08 pm   Post subject: (No subject)

Integer.parseInt(myInteger).charAt(i)
bugzpodder




PostPosted: Sat Sep 16, 2006 8:09 pm   Post subject: (No subject)

return (myInteger/Math.pow(10,i))%10
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: