Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to generate a random number between a range of value say from (-10 to 10).
The generated random number should be same for any number of attempts in this range.

If -10 to 10 give 4.526325631
then if i give -10 to 10 for 100 times then the number generated should be 4.526325631.

How can i acheive it?
Posted

Don't use random numbers.

What part of the phrase "Random number" is confusing you?
When you generate a random number between an upper an a lower limit you have no idea what the number will be - that is the whole idea of "random" Over time and sufficient numbers it will trend to the mean of the upper and lower bounds, but you cannot skew it towards any particular value - or it looses all semblance of randomness.
 
Share this answer
 
See this Article[^]
 
Share this answer
 
Hello,

Can you please clarify, you state you want a random number but then you state the number should always be 4.526325631.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900