Computing.Net > Forums > Programming > Large Random Numbers in C++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Large Random Numbers in C++

Reply to Message Icon

Name: zpeterz63
Date: January 14, 2005 at 12:18:41 Pacific
OS: Mandrake 10.1/XP dual boo
CPU/Ram: 2.4 Celeron/512
Comment:

I'm looking for a way to large random numbers beyond the limit of rand(). I have an idea on how I can do this but was wondering if C++ by chance had anything to help me out built in or if someone how found a convenient way to do this.



Sponsored Link
Ads by Google

Response Number 1
Name: BlueRaja
Date: January 14, 2005 at 16:17:44 Pacific
Reply:

Well the easy thing to do would be to add two rand()'s and modulus them..
The best and most practical thing to do would be to write your own png, or find one meant for larger numbers on the internet; google it.

BlueRaja.admin@gmail.com


0

Response Number 2
Name: Wolfbone
Date: January 14, 2005 at 16:26:40 Pacific
Reply:

Use the GMP library. I don't know if it's ported/portable to Windows or not but it's the best there is (pari/gp uses it). The Mandrake distro already has it but here's the website anyway:

http://www.swox.com/gmp/

Getting random numbers out of GMP isn't too difficult but I found the documentation can be quite confusing so here's a natural number example which uses the high quality entropy pool in /dev/random and is the only use I've ever made of GMP's random number facilities anyway :)



0

Response Number 3
Name: Wolfbone
Date: January 14, 2005 at 17:12:08 Pacific
Reply:

Sorry about the awful code - it's from among my earliest attempts in C. I've just removed a couple of obvious stupidities but there are probably others.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Large Random Numbers in C++

Random numbers www.computing.net/answers/programming/random-numbers/8428.html

Random Numbers in Java www.computing.net/answers/programming/random-numbers-in-java/8564.html

Random numbers in ASSEMBLY www.computing.net/answers/programming/random-numbers-in-assembly/9466.html