Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-13-2008, 01:11 PM
Member
 
Join Date: Jun 2008
Posts: 23
jithan is on a distinguished road
Random number
hello friends,
i want to generate a 32 digit random number...........pls help me....... its very urgent...........

Thanks in advance.........
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-13-2008, 02:42 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 524
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
If i were to do that( in integer),

Since the maximum positive integer in java is (2 power 31)-1,

i may use a next random number of 9 power 15,
Code:
int val = new Random().nextInt(9 power 15);
filter all those value less than 1 power 15 except the greater values.....(to have a 16 digit value)

store in a temp variable,
Same procedure again, store in another variable,

Convert the two integer values into String, then use the concat method....(I should show first the output to insure that my algorithm is right)

In Long, you can use directly the nextLong(Long val) to generate values.... by filtering the generated value except the requirement,
You can now have your 32 digit random digit number....
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 06-13-2008 at 02:47 PM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
random numbers without random class` carlos123 New To Java 4 01-17-2008 11:44 PM
Random Generator padutch2 New To Java 1 12-03-2007 07:43 PM
Generate a random number romina New To Java 1 08-07-2007 06:23 AM
How to generate random number in java fernando New To Java 1 08-01-2007 08:32 PM
Random Image on Refresh (FROM Folder not set number) QuinnMal Java Servlet 1 07-06-2007 08:27 PM


All times are GMT +3. The time now is 12:38 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org