It’s common for random number functions to use an inclusive lower bound and an exclusive upper bound because of the way the limited is implemented.
(Usually people just use the modulo (
%) operator, despite the fact it introduces bias.)
The best names would be
exclusiveUpperBound but some people might think that’s a bit long.
In fact all of C++'s fancy random number classes do it, and I dare say it does make more sense to do it that way.
Unfortunately in this case the
random function exists in an attempt to be compatible with Arduino, so we have to go with what they chose.
@FManga knows, he was just giving a real world example (that’s what asterocks actually does sadly).
I admire your battle against ‘magic numbers’ though.
Personally I say prefer
constexpr const over
#define pollutes the whole code among other issues.