BinaryByter
So this a % b will NEVER be bigger than b
BinaryByter
so this is the first part
BinaryByter
random () % b
random () generates a huge random number. by using modulo on it, you ensure that it never becomes bigger than b
BinaryByter
Now since you have a range, you might not want to start at 0
BinaryByter
So by adding min to the random number, the number 0 will be mapped to min
BinaryByter
but this might cause the biggest possible number to be wayy higher than the upper bound of the range
BinaryByter
thats why we have
random () % (max - min)
Ariana
DONT USE RANDOM
anyways
get random data from urandom :)
BinaryByter
So in total we have
(random () % (max - min)) + min
^ ^ ^
gen number how many ensure the smallest
in the range? number to be in the range
BinaryByter
BinaryByter
urandom isnt available on windows
BinaryByter
+ it requires quite a hackjob with FILE structs
Ariana
lmao screw windows user
just help them install a malware and be happy
Anonymous
Anonymous
that's what i don't understand
BinaryByter
Ariana
%n -> all numbers are in the range from 0 to n-1
+x -> all numbers are in the range from x to x+n-1
BinaryByter
BinaryByter
:D
Ariana
:D
BinaryByter
but windows is really just better because of the frontend
Ariana
ok be happy we aren't on windows
Ariana
nononono i cant find | grep
Ariana
how do i find my file then
Ariana
;-;
Ariana
:D
BinaryByter
Ariana
Ariana
;-;
BinaryByter
just become german
Anonymous
Anonymous
with this method
BinaryByter
BinaryByter
BinaryByter
read what I told you 😂
Anonymous
did you?
Ariana
%n -> 0,1,2,3...n-1
%n+x -> x,x+1,x+2,...,x+n-1
So set x as min and x+n-1 as max, then x=min and n=max+1-min
So you take
rand()%(max+1-min)+min
BinaryByter
Anonymous
BinaryByter
Anonymous
how am i sure of that?
BinaryByter
😂
Ariana
Let's say
max=10
min=5
rand()%(10-5+1)=rand()%(6)
all the possible outputs are 0,1,2,3,4,5
Now we add 5, so it becomes rand()%6+5
all the possible outputs are 5,6,7,8,9,10
BinaryByter
Ariana
Let's say
max=10
min=5
rand()%(10-5+1)=rand()%(6)
all the possible outputs are 0,1,2,3,4,5
Now we add 5, so it becomes rand()%6+5
all the possible outputs are 5,6,7,8,9,10
this is ok?
Anonymous
Let's say
max=10
min=5
rand()%(10-5+1)=rand()%(6)
all the possible outputs are 0,1,2,3,4,5
Now we add 5, so it becomes rand()%6+5
all the possible outputs are 5,6,7,8,9,10
no
Anonymous
shouldn't random() return just 1 value?
BinaryByter
it should :D
Ariana
ok...
BinaryByter
Ariana
Let's say
max=10
min=5
rand()%(10-5+1)=rand()%(6)
all the possible outputs are 0,1,2,3,4,5
Now we add 5, so it becomes rand()%6+5
all the possible outputs are 5,6,7,8,9,10
Commit message: fixed english
BinaryByter
Ariana
now wheres my hacktober tshirt
Anonymous
Ariana
XD
BinaryByter
BinaryByter
and I am jealous
BinaryByter
:(
Ariana
BinaryByter
wait why
appearently they were too stupid to print my adress well 😂
Ariana
XD
Ariana
omg rip
BinaryByter
yes, very rip
Ariana
this is why i make by address as detailed as it possibly can
Anonymous
i tried it, it works
BinaryByter
Anonymous
the problem is that i don't know the why
Ariana
^
Ariana
Let's say
max=10
min=5
rand()%(10-5+1)=rand()%(6)
all the possible outputs are 0,1,2,3,4,5
Now we add 5, so it becomes rand()%6+5
all the possible outputs are 5,6,7,8,9,10
this zis ok
BinaryByter
Ariana
这个可以吗