jeudi 9 novembre 2017

How to generate as close as I can get to random integer in C++17 within a specified range?

System: Linux Mint 18 Cinnamon 64-bit (the base being Ubuntu 16.04).

Intention: I am learning C++ starting with basics on the C++17 standard with compiler:

g++-5.real (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609

Compilation procedure:

g++ source.cpp -std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors -o "program"

I don't know if there is a newer version of the standard or the compiler, but for the sake of this question, let's suppose there are none newer.

My head is spinning from websites like http://ift.tt/1uEED7V

I don't understand any of that, so I have a question for you:


How to generate as close as I can get to random integer in C++17 within a specified range?


Meaning mostly, IMHO, it should not have uniform distribution, as it would decrease the randomness, but I may be mistaken?

Is this possible answer or maybe this? I don't know, because they were written in 2015 / 2013 and I say: Is there's already better approach?




Aucun commentaire:

Enregistrer un commentaire