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
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
that's what i don't understand
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
Ariana
Linux isn't much better?
dude i tried using windows yesterday, just be happy we're on linux
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
;-;
BinaryByter
ok be happy we aren't on windows
lets be happy that we can still use dos on emulators :D
Ariana
:D
BinaryByter
anyways this make sense?
prolly not, formal maths are always hard to get for nonchinese people 😝
Ariana
;-;
BinaryByter
just become german
Anonymous
but how do i ensure the highest number to be smaller than max?
this is literally the only problem that i have
Anonymous
with this method
Anonymous
just become german
Hitler 1945 (Colorised)
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
Ariana
read what I told you 😂
youres cant output max unless max is like an unwanted child
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
^ (max - min) makes sure that no number is bigger than what is allowed in the range. the + min at the end just shifts everything by min
Anonymous
how am i sure of that?
BinaryByter
how am i sure of that?
black magic, be contempt with 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
Anonymous
black magic, be contempt with that
"because reasons" is not acceptable for me
Anonymous
shouldn't random() return just 1 value?
BinaryByter
it should :D
Ariana
ok...
BinaryByter
ok...
😂
BinaryByter
Commit message: fixed english
I pardon your french!
Ariana
now wheres my hacktober tshirt
Anonymous
Ariana
XD
BinaryByter
now wheres my hacktober tshirt
I didn't get mine
BinaryByter
and I am jealous
BinaryByter
:(
Ariana
Commit message: fixed english
Commit suicide: fixed english
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
i tried it, it works
No shit sherlock
Anonymous
the problem is that i don't know the why
Ariana
^
BinaryByter
the problem is that i don't know the why
you know it, you prolly overread it ¯\_(ツ)_/¯
BinaryByter
^
❤️
Ariana
这个可以吗