13,089,610 members (47,081 online)
Rate this:
See more: (untagged)
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 3-Dec-12 4:53am

Rate this:

Solution 3

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.
Rate this:

Rate this:

Solution 1

Hello,

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

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

Top Experts
Last 24hrsThis month
 ProgramFOX 270 Richard Deeming 220 Jochen Arndt 160 OriginalGriff 155 Graeme_Grant 140
 OriginalGriff 3,402 Graeme_Grant 1,784 ProgramFOX 1,707 Jochen Arndt 1,645 ppolymorphe 1,487

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 3 Dec 2012