Click here to Skip to main content
11,481,916 members (65,094 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/CLI
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 5:53am
Rate this: bad
good
Please Sign up or sign in to vote.

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

See this Article[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

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.
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100