Hi again again!
I manage to get my e_mail back. So, don't take into account my previous
mail!
Thanks a lot for your numerous answers about random, I will try immediately!
Nathalie
Marco van de Voort wrote:
> > In GPC, in may be very large, e.g.:
>
> <snip>
>
> > a := Random (1000000000000000000);
>
> Random has a 64-bit definition? Or both 64 and 32 with overloading?
The internal RNG is 32 bit, but is a 64 bit number is wanted, Random
calls it twice.
The `Random' function is overloaded (with compiler magic) for
LongestReal and LongestCard (i.e., the longest available real and
(unsigned) integer types -- this may by 64 bit, or 128 …
[View More]bit on 64 bit
systems).
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
[View Less]
George Shapovalov wrote:
> var N:any_integer_type; (may be not extended (very large) integer integer)
> random(N); would return integer type in the range 0..N-1
In GPC, in may be very large, e.g.:
program Foo;
var a : LongInt;
begin
a := Random (1000000000000000000);
Writeln (a)
end.
> random; (without parameters) would return float in the range 0..1.
(with 0 inclusively and 1 exclusively)
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, …
[View More]latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
[View Less]
Hi,
I'd like to use random numbers generator.
Is someone knows some efficient procedures or functions in pascal?
Thanks a lot in advance for your help,
Nathalie
Hi,
after Russ Whitaker has updated the FAQ (thanks!), I've discovered a
problem:
The old version of the FAQ was written in Texinfo. A version
translated to ASCII was distributed with GPC, and that's proabably
all you've seen, Russ, and consequently edited this version.
Now, it would be nice to have the current FAQ in Texinfo format
again. Then we could, e.g., provide an HTML version on the GPC home
page and include it into GPC's documentation (and it could also
contain direct cross-links to …
[View More]the various URLs and to other Info
files, e.g. the DJGPP FAQ).
So, would you be willing to convert the FAQ back to Texinfo? This
would be greatly appreciated.
FYI, a Texinfo version of the old FAQ can be found at
ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib/gpc-faq-0.4.tar.gz
(in case you want to check how some formatting was done there, etc.)
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
[View Less]
Russ Whitaker wrote:
> Does the Standards Committiee still exist?
I think the members meet at irregular time intervals. Some (or at
least one) of them is reading c.l.p.a-i, so you might want to post
there...
> It would be nice to
> start the ball rolling tward a rewrite, even if nothing more than
> a conversion into real english.
Unlikely. However, be invited to help improving the GPC
documentation where real English descriptions of this and many other
features are urgently …
[View More]needed.
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
[View Less]
Hi
Sounds like someone tried to define Pascal by using a Flow Chart
and someone else converted the Flow Chart itself into english :-)
Does the Standards Committiee still exist? It would be nice to
start the ball rolling tward a rewrite, even if nothing more than
a conversion into real english.
In the meanwhile, just for fun patched the original program that
started this thread:
program prime1; {find prime numbers up to 100}
var
i,j,k: integer;
begin
for i := 2 to 100 do
begin
k …
[View More]:= 0;
for j := 2 to i do
if i mod j = 0 then
begin
k := j;
break;
end;
if k = i then
writeln( k );
end;
end.
It prints out 25 prime numbers 2,3,5, ... ,97
useing 1158 passes through the inner loop.
program prime2; {find prime numbers up to 100}
var
i,j: integer;
k: boolean;
begin
for i := 2 to 100 do
begin
k := false;
j := 1;
repeat
inc( j );
if i mod j = 0 then
k := true;
until( k or ( j > sqrt( i )));
if not k or ( j = i ) then
writeln( i );
end;
end.
It prints out the same list useing 261 passes
Russ <russwhit(a)mind.net>
[View Less]
J. David Bryan wrote:
> On 20 May 2000, at 9:31, Russ Whitaker wrote:
>
> > So what does the Pascal specs say?
>
> The Extended Pascal standard, section 6.9.3.9.1, says:
>
> "After a for-statement is executed, other than being left by a
> goto-statement, the control-variable shall be undefined."
>
> That's remarkably clear. :-) That means that variable "b" in the code
> below isn't guaranteed to be true:
In fact, i = 10 in the current GPC …
[View More]version (but don't rely on it :-).
> procedure p;
> var i : integer;
> b : Boolean;
> begin
> for i := 1 to 10 do ;
> b := (i > 10);
> end;
> The next part of the standard is a bit less clear:
>
> "Neither a for-statement nor any procedure-and-function-declaration-part
> of the block that closest-contains a for-statement shall contain a
> statement threatening (see 6.9.4) a variable-access denoting the
> variable denoted by the control-variable of the for-statement."
>
> I believe that says that you can't modify the control variable of a for-
> statement (a "threat" is defined in the standard as one of ten ways that a
> variable may be assigned a value).
Including a `for' statement (item g :-). Therefore I conclude that a
`for' statement by itself is illegal in Pascal. Alright, we'll take
it out of the next GPC release. Just kidding...
> So this would clearly be illegal:
>
> procedure p;
> var i : integer;
> begin
> for i := 1 to 10 do
> i := 11;
> end;
>
> However, it also says that a block containing a for-statement cannot
> contain a threat to the control variable. In other words, this would be
> illegal too:
>
> procedure p;
> var i : integer;
> begin
> i := 0;
> for i := 1 to 10 do
> end;
>
> I suppose the reason is to disallow something like this:
>
> procedure p;
> var i : integer;
> label 1, 2, 3;
> begin
> goto 1;
> 2: i := 11;
> goto 3;
>
> 1: for i := 1 to 10 do
> begin
> goto 2;
> 3:
> end
> end;
>
> ...which is functionally equivalent to the second code example.
Yes, but is a goto into a loop legal at all (the last sentence of
6.9.2.4 seems to indicate not to me, but I'm not completely sure)?
If it is legal, what should the following code do?
procedure p;
var i : integer = 42;
label 1;
begin
goto 1;
for i := 1 to 10 do
begin
1: Writeln (i)
end
end;
> So it would seem that to comply with the EP standard, GPC must prohibit any
> threat (i.e., variable assignment) to a for-statement control variable
> anywhere within the scope of that variable, and not just within the for-
> statement itself.
This would mean that the loop variable could practically not be used
outside of the for loop. If this is really true, I'd really favour a
syntax that makes this clear (like `for i : Integer = 1 to 10 do ...'),
so i has only the corresponding scope.
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
[View Less]
J. David Bryan wrote:
> Hello Marco,
>
> I have copied my reply to the list.
>
>
> On 21 May 2000, at 15:56, Marco van de Voort wrote:
>
> > Or do they mean:
> >
> > procedure x;
> >
> > var i : integer;
> >
> > procedure nestedx;
> >
> > begin
> > i:=5;
> > end;
> >
> > begin
> > for i:=1 to 5 do nestedx;
> > end;
>
> I believe you are correct, and my original …
[View More]reading that:
>
> i := 0;
> for i := 1 to 10 do ;
>
> was incorrect is itself incorrect. The key part of the statement in the
> standard is that the "...procedure-and-function-definition part of the
> block that closest-contains a for-statement..." cannot threaten the control
> variable. In your example, the "procedure x" block (the second begin-end
> block) is the "block that closest-contains a for-statement." Therefore,
> your first block, that of "procedure nestedx", forms the "procedure-and-
> function-definition-part of the block...."
>
> So your example breaks the requirement listed in the standard, meaning your
> interpretation is correct. In my example, the threat ("i := 0") is not in
> either the for-statement nor the procedure-and-function-definition part, so
> it is legal.
I see. So `for' statement are not illegal by themselves in Pascal,
I'm relieved. ;-)
Checking all this seems quite difficult, but at least in principle
possible...
Frank
--
Frank Heckenbach, frank(a)g-n-u.de, http://fjf.gnu.de/
GPC To-Do list, latest features, fixed bugs:
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
[View Less]