So I have a function that gives me random bits rand(0,1) i want to generalize this to rand(a,b) that gives me a random number in the range a to b.
My idea is to just calculate the amount of bits in b - a and then append them together. I think this will work but it's not going to be uniform. I feel like it will favor larger numbers as opposed to smaller numbers(numbers closer to a). Not really asking for a straight up answer just some help would be nice.
EDIT: This is my idea so far, just not sure on the uniform part
pseudo code:
function rand_range(a, b):
n = b - a
sum = a
for i in range(n):
sum += rand(0,1)
return sum