MakeRandomString

Share your advanced PureBasic knowledge/code with the community.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: MakeRandomString

Post by heartbone »

STARGÅTE wrote:

Code: Select all

Random=Random(25,0)
Random%10
This is no uniform distribution, because you get more numbers between 0 and 5 than numbers between 6 and 9.
Good catch about the distribution, but somewhat misleading since all the numbers possible with that code are between 0 and 5.

What blows me away is infratec's Random('Z', 'A') and Random('9', '0').
Keep it BASIC.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: MakeRandomString

Post by Mistrel »

heartbone wrote:What blows me away is infratec's Random('Z', 'A').
When specifying a character using single quotes, it translates into the ASCII (integer) form.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: MakeRandomString

Post by heartbone »

Wow that's good to know Mistrel, I had missed that information.
I surely need to increase my screen font size, because I now see the mod and not a divide above.
Another miss. :(
So never mind about the math incorrection STARGÅTE.
Keep it BASIC.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: MakeRandomString

Post by PB »

> 99 out of a 100 flips would break any casino

Yep, but that doesn't mean it's not random.

As I said, randomness means you don't get to choose
what the result is, nor do you get to reject a run of
random results just because it doesn't "look right".
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: MakeRandomString

Post by Mistrel »

PB, I think you're confusing random with pseudorandom.
Post Reply