473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to rand() numbers more than 32768 in Microsoft platform?

20
HI ALL!
Pls help. I meet a prob
rand(NN);
NN is equal to 54756
the randomize numbers stop at 32768 n not 54756
Any codes that can make it?
i m currently using Microsoft Visual Studio to write C.
Really appreciate if u all cn help coz i m a beginner in C.
Thanks
Jul 12 '07 #1
2 2241
JosAH
11,448 Expert 8TB
HI ALL!
Pls help. I meet a prob
rand(NN);
NN is equal to 54756
the randomize numbers stop at 32768 n not 54756
Any codes that can make it?
i m currently using Microsoft Visual Studio to write C.
Really appreciate if u all cn help coz i m a beginner in C.
Thanks
Supose both r1 and r2 are pseudo random numbers in the range [0,1<<15)
(the normal rand() range), then (((long)r1)<<15)|r2 is a random number in the
range [0,1<<30). Is that large enough for you?

kind regards,

Jos
Jul 12 '07 #2
TommyC
20
Thank you very much. Can u show me how to imply into my program because i'm a beginner of C programming?This is part of my program:
#define RANDOMIZE() srand((unsigned int)time(NULL))
#define RANDOM(x) (rand()%(x))

void histogram()}
int i,j,k,r;
int cnt;
int rnd;
int setrandom();
:
:
for(r=0;r<NN;r++){
AA[r] = 0;
}
cnt = 0;
L1:; //loop
rnd = RANDOM(NN); //NN=54756
if(AA[rnd] == 0){
cnt++;
printf("cnt=%d",cnt);}
Jul 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: daniel kaplan | last post by:
so i generate a serial number with the exact code below (three lines): $number1 = 10000 + int(rand(99999)); $number2 = 10000 + int(rand(99999)); $shrwsn = "$number1-$number2"; the point is i...
5
by: lallous | last post by:
Hello, This code works fine when 'size' is less than 32768 however when size is bigger this function never returns. Can't find out why?! If I break into the code I can see that 'i' is 32768.......
7
by: Chris Gordon-Smith | last post by:
I have a simulation program that calls the rand() function at various points while it executes. For the user interface that displays statistics etc. while the program runs, I use the Lazarus GUI...
36
by: Ben Justice | last post by:
For a program in c, I need some random numbers for a system were people are placing bets. This is not a commerical project btw. Generally, I tend to rely on things from the standard library,...
11
by: Fernando Barsoba | last post by:
Hi all, I think this has been posted many times.. but I tried several recipes for obtaining a random number between , but I can't make them work. So, does anyone know how to generate random...
4
by: Siam | last post by:
Hi all, I'm writing a shell language in c++ that supports the generation of random numbers, and by its nature, each command must be executed in a new thread. The call to the random function from...
13
by: Spiros Bousbouras | last post by:
The standard says that rand() should return a pseudo-random number but what does pseudorandom mean ? If an implementation of rand() always returned the same number would it be conforming ? What if...
5
by: ds | last post by:
Hi all, rand() is not thread safe, a fact that may not be so bad after all.. However, I face the following problem: a piece of code uses rand() to get a random sequence, but always seeds with...
15
by: Rich Fife | last post by:
Quick rand() question: I know you're not supposed to use "rand() % 1024" for instance, because it focuses on the lower bits. However, it seems to me that given that the argument is not a power...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.