I don't understand QRandomGenerator.
-
If you need boundaries then use
bounded()
instead ofgenerate()
.
It will not change themin()
/max()
result but it returns the bounded result directly.BTW, mine
QRandomGenerator::max()
returns 4294967295 andQRandomGenerator64::max()
returns 18446744073709551615.
So if you are usingQRandomGenerator64
which returns aquint64
value and assign the result to anint
, then it is normal to get a negative number . -
@tsvigo
Not sure quite what you mean or if there is still a question?QRandomGenerator
has overloads which returnquint32
orquint64
withgenerate[64]()
andbounded()
. If necessary pass your desired maximum value tobounded()
.The return values of
quint32
orquint64
are not "negative", they are unsigned/positive. What you do with that and when "written through the number" is a different matter.