From 248f0e73718b7f2d192f019b809a547fa2ceb933 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Wed, 22 Jan 2025 13:38:00 +0100 Subject: [PATCH] Change probability calculation Instead of using lower/higher halves of the return range use modulo 2. This is easier to generalize. --- ex03/RobotomyRequestForm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ex03/RobotomyRequestForm.cpp b/ex03/RobotomyRequestForm.cpp index 763156b..c217ff5 100644 --- a/ex03/RobotomyRequestForm.cpp +++ b/ex03/RobotomyRequestForm.cpp @@ -40,7 +40,7 @@ bool RobotomyRequestForm::getRandomBit() std::srand(std::time(0)); is_seeded = 1; } - return (std::rand() > (RAND_MAX / 2)); + return (std::rand() % 2); } RobotomyRequestForm *RobotomyRequestForm::createNew(const std::string &target) const -- 2.30.2