So I created a really terrible function in which is made just to generate random numbers, I was given that RINT is a built-in function that generates any integer 0-255 INCLUSIVE.
BEGIN RanInt(Low, High, Result)
tmpA = RINT
Range = High - Low + 1
tmpB = tmpA/256 * Range
tmpC = int(tmpB)
tmpD = tmpC + Low
Result = tmpD
END RanInt
Now, using my function, I have to analyse why this function will not generate each possible number with equal likelihood. Firstly, will I approach this question about the actual computer hardware? Or the fact that the possible chance of each number occuring in equal likelihood must be divisible by the range of numbers that can specified in the RanInt function? Thanks!!
Aucun commentaire:
Enregistrer un commentaire