🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #197

Re: Randomize and Random

#197
From: Sven Pran
Date: Mon, 26 Jan 2004 14:33
38 lines
2065 bytes
"Martin Strand"  wrote
> Sven Pran wrote:
>
> > "Eugene V. Goldberg" <egold@mts-nn.ru> wrote in message
>
> >> function TfrmTickets.GetPassword: String;
> >> var
> >>   i, Digit: Integer;
> >> begin
> >>   Randomize;
> >>   Result := '';
> >>   for i := 1 to 8 do
> >>   begin
> >>     Digit := Random(10);
> >>     if Digit = 0 then
> >>       Digit := 1;
> >>     Result := Result + IntToStr(Digit)
> >>   end;
> >> end;
>
> > Digit := Random(10) generates a single number (digit) in the range
> > 0..9 and then you change every occurrence of the digit 0 to digit 1
> >
> > This results is no zero digits and twice the count of number one
> > digits to what I assume you want (equal probability for each digit in
> > the range)?
>
> ... so a better solution would be
>   Digit := Random(Highest-1)+1;
> In this case, your numbers will be in the range 1..Highest.

No, they will be in the range 1 to Highest-1 !

All passwords I have ever seen when they consist of numerical digits
cosist of digits in the range '0' to '9', not '1' to some "highest digit".

Sven
Technical Details
Message-ID: <4015253a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4014fbf5@newsgroups.borland.com> <401501e6@newsgroups.borland.com> <40151efd@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,64bfe8b17e3a4cc8
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2004-01-26 06:39:58 PST
From: "Sven Pran" <no.direct@mail.please>
Newsgroups: borland.public.delphi.language.objectpascal
References: <4014fbf5@newsgroups.borland.com> <401501e6@newsgroups.borland.com> <40151efd@newsgroups.borland.com>
Subject: Re: Randomize and Random
Date: Mon, 26 Jan 2004 15:33:29 +0100
Lines: 40
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 83.108.10.156
Message-ID: <4015253a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075127610 83.108.10.156 (26 Jan 2004 06:33:30 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail