std::uniform_real_distribution max() method in C++ with Examples

The max() method of uniform_real_distribution class in C++ is used to get the maximum possible value that can be generated by this uniform_real_distribution.

Syntax:

result_type max() const;

Parameters: This method do not accepts any parameters.



Return Value: This method return the maximum possibly generated value in this uniform_real_distribution.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ code to demonstrate
// the working of max() function
  
#include <iostream>
  
// for uniform_real_distribution function
#include <random>
  
using namespace std;
  
int main()
{
    double a = 10, b = 20.5;
  
    // Initializing of uniform_real_distribution class
    uniform_real_distribution<double> distribution(a, b);
  
    // Using max()
    cout << "Max value that can be generated"
         << " by this uniform_real_distribution: "
         << distribution.max() << endl;
  
    return 0;
}

chevron_right


Output:

Max value that can be generated by this uniform_real_distribution: 20.5

Reference: http://www.cplusplus.com/reference/random/uniform_real_distribution/max/



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.