Hiya, I have a int x = 28492374 and need to add every other digit together and then later do other stuff with the digits like take every other digit and multiple by two then add each digit together. Anways i dont know the method call out a single digit from an int.
Member 785230
0
Newbie Poster
Recommended Answers
Jump to PostYou should know the classes and their methods:
java.lang.Integer
java.lang.Stringfor example:
java.lang.String st = java.lang.Integer.toString(x);
Jump to Posta single digit from an int
It depends on the number's base. You use the modulus and divide operators to get at the "digits" of the int number. For base 10 use % 10 and / 10
Remember all data is stored in the computer in binary.
We humans like …
All 6 Replies
Member 785348
0
Newbie Poster
quuba
81
Posting Pro
NormR1
563
Posting Sage
Team Colleague
Prateek Jauhari
0
Newbie Poster
NormR1
563
Posting Sage
Team Colleague
Prateek Jauhari
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.