|
Convert a Keno Game Number into 15 Bytes
The previous tutorial showed you how to convert a Keno Game Number (KNG) into a single number.
There is enough data in a single Keno Game Number to generate up to 15 bytes of data.
I converted the KGN into 15 bytes to test KenoRND() for randomness, so this will discuss the formulas I used.
1) Compare the KGN to 33,597,959,929,403,479,330,212,472,780,800,000.
a) If it is less than that number than the first byte is 0 (in decimal form)
b) If it is greater than that number then add that number to itself and compare it to the KGN again
i) If it is less than that number than the first byte is 1
ii) If it is greater than that number, then add the number in 1 to the number in 1b and repeat this process until you determine the first byte.
2) Multiply the number from step 1 times the decimal representation of the first byte and subtract this value from the KGN
3) Take the value from #2 and repeat steps 1 and 2 using the following numbers in replace of step 1's number:
a) 131,242,030,974,232,341,133,642,471,800,000
b) 512,664,183,493,095,082,553,290,905,468.75
c) 2,002,594,466,769,902,666,223,792,599.4873046875
d) 7,822,634,635,819,932,289,936,689.841747283935546875
e) 30,557,166,546,171,610,507,565.19469432532787322998046875
f) 119,363,931,820,982,853,545.1765417747083120048046112060546875
g) 466,265,358,675,714,271.660845866307454343768768012523651123046875
h) 1,821,349,057,327,008.87367517916526349353034675004892051219940185546875
i) 7,114,644,755,183.6284127936686143105216029169923785957507789134979248046875
j) 27,791,581,074.936048487475268024650475011394501478889651480130851268768310546875
k) 108,560,863.57396893940420026572129091801325977140191270109426113776862621307373046875
l) 424,065.8733358161695476572879737926484892959820387214886494575694086961448192596435546875
m) 1,656.507317718031912295536281147627533161312429838755815036943630502719315700232982635498046875
n) 6.47073170983606215740443859823292005141137667905763990248806105665124732695403508841991424560546875
Now you have your 15 bytes.
I just through the remainder away, but if you come up with a better idea of what to do with it, let me know.
You can use the same system to get other things besides bytes out of a KGN.
For instance if you want to generate multiple numbers from 1 to 10, then you would run the same basic steps above, but your multipliers would be different.
The above multipliers are from taking the total number of possible Keno outcomes, dividing that number by 256 and that gives you the number for step 1, then divide that by 256 and that gives you the number for 3a, etc.
Note that if the language of your choosing doesn't handle numbers as large as the denominator in step 2, you won't get an accurate result.
|