Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
std::experimental::randint(3) C++ Standard Libarystd::experimental::randint(3)

NAME
       std::experimental::randint - std::experimental::randint

Synopsis
	  Defined in header <experimental/random>
	  template  <class  IntType>		      (library fundamentals TS
       v2)
	  IntType randint(IntType a, IntType b);

	  Generates a random integer in	the closed interval [a,	b].

Parameters
	  a, b - integer values	specifying the range

Return value
	  A random integer i in	the closed interval [a,	b], produced  using  a
       thread-local
	  instance  of std::uniform_int_distribution<IntType> invoked with the
       per-thread
	  random number	engine.

	 Remarks

	  If IntType is	not one	of  short,  int,  long,	 long  long,  unsigned
       short, unsigned int,
	  unsigned long, or unsigned long long,	the program is ill-formed.

	  The behavior is undefined if a > b.

Example
       // Run this code

	#include <iostream>
	#include <experimental/random>

	int main()
	{
	    int	random_number =	std::experimental::randint(100,	999);
	    std::cout << "random 3-digit number: " << random_number << '\n';
	}

Possible output:
	random 3-digit number: 273

See also
	  reseed reseeds the per-thread	random engine
		 (function)

http://cppreference.com		  2022.07.31	 std::experimental::randint(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::experimental::randint&sektion=3&manpath=FreeBSD+Ports+15.0>

home | help