0Pricing
C++ Academy · Lesson

Random Numbers with the random Header

Generate quality random numbers with modern engines and distributions.

Why Not rand()?

The legacy C std::rand() uses a global state, has poor statistical quality, and is not thread safe. Modern C++ provides much better tools in <random>.

The Three-Part Recipe

Random numbers in modern C++ involve three pieces:

  • A seed source (true entropy)
  • A generator engine (deterministic state)
  • A distribution (shapes the output)

All lessons in this course

  1. Integer vs Floating Point Types
  2. The cmath Header: pow sqrt abs round
  3. Random Numbers with the random Header
  4. Numeric Limits and Overflow Behaviour
← Back to C++ Academy