Advertisement
Guest User

random double generator between interval

a guest
Feb 19th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. double randomDouble2( double low_bound, double high_bound )
  2. {
  3.     static bool didSeeding = false;
  4.  
  5.     if (low_bound > high_bound){
  6.         std::swap(low_bound, high_bound);
  7.     }
  8.  
  9.     if (!didSeeding) {
  10.         std::mt19937 engine;
  11.         didSeeding = true;
  12.     }
  13.  
  14.     return std::uniform_real_distribution<>( low_bound, high_bound )( engine );
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement