title: floating point random number in c++
body: <p>hi i am trying to write a code for random numbers between -1 and 1 like :
  0.9
  0.3
  0.8
  but i can get only numbers like 1 2 3 5 etc using this code</p>
  
  <pre><code>rand()%(max-min + 1) + min
  </code></pre>
  
  <p>is there any direct function in c++ .if not how can i achieve it</p>
  
  <p>the complete programis :</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cstdlib&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  class perceptron{
      public:
          vector &lt;float&gt; weights;
          int max=5,min=1;
          perceptron( float n){
              for( int i=0 ;i&lt; n; i++){
  
                  weights.push_back(rand()%(max-min + 1) + min);
                  cout&lt;&lt;weights[i]&lt;&lt;",";
          }
      }
  };
  int main(){
      perceptron p1(4);
      return 0;
  }
  </code></pre>