Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

number conversion

Thread view: 
usgog@yahoo.com - 28 Jul 2006 02:13 GMT
I need some help to do number conversion...:

I got a 9 digit integer from another function (say int A = 123456789)
and need to make a 4 digit one (int B, say 6789) from A. Then I send B
to user.

User types in 4 digit integer (int C) and I check whether B == C. If
true, then I convert B to back to A again.

So how can I convert A to B and then B to A? Any algorithm I can use,
say get the last four digit of A?
Lee Weiner - 28 Jul 2006 02:47 GMT
>I need some help to do number conversion...:
>
[quoted text clipped - 7 lines]
>So how can I convert A to B and then B to A? Any algorithm I can use,
>say get the last four digit of A?

Mod A with 10000:

int B = A % 10000;

Why do you have to convert B back to A?  Don't you still have the value of A
stored in a variable?  It's still there.

Lee Weiner
lee AT leeweiner DOT org
usgog@yahoo.com - 28 Jul 2006 03:17 GMT
You are correct...Thanks!

> >I need some help to do number conversion...:
> >
[quoted text clipped - 17 lines]
> Lee Weiner
> lee AT leeweiner DOT org


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.