Re: [fpc-pascal] Bug in documentation for Random?

2017-04-05 Thread Giuliano Colla

Il 05/04/2017 18:09, Bart ha scritto:

http://www.freepascal.org/docs-html/current/rtl/system/random.html

"Random returns a random number larger or equal to 0 and strictly less than L"

However random(a negative number) returns a number <= 0 and > L


program r;
begin
   randomize;
   writeln('Random(-10) = ',Random(-10));
end.

C:\Users\Bart\LazarusProjecten>test
random(-10) = -1
C:\Users\Bart\LazarusProjecten>test
random(-10) = -4

Maybe my understanding of English ("strictly less than") is not
correct, so I ask here before posting as a bugreport.



My scant knowledge of English leads me to believe that the sentence 
should be rephrased in order to cover the negative numbers case:


either:

   Random return a random number with the same sign of L, and whose
   absolute value is larger or equal to zero and strictly less than the
   absolute value of L.

or:

   Random return a random number in the range 0 (included) to L (excluded).

Just my 2c.

Giuliano

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Bug in documentation for Random?

2017-04-05 Thread Bart
On 4/5/17, Santiago A.  wrote:

> random(-10)
> will output numbres -9..0

That was not realy the question.
The question is wether the documentation is wrong, or the
implementation or neither.

B.t.w. Delphi7 gives me:
Random(-10) = -776108169
Random(-10) = 244426112
Random(-10) = -1774796928
Random(-10) = 1443026331
Random(-10) = -919853036
Random(-10) = -747947900
Random(-10) = -1767321924
Random(-10) = -2114448955
Random(-10) = 1499268340
Random(-10) = -1658783534
(which makes no sense at all to me...)

Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Bug in documentation for Random?

2017-04-05 Thread Bart
http://www.freepascal.org/docs-html/current/rtl/system/random.html

"Random returns a random number larger or equal to 0 and strictly less than L"

However random(a negative number) returns a number <= 0 and > L


program r;
begin
  randomize;
  writeln('Random(-10) = ',Random(-10));
end.

C:\Users\Bart\LazarusProjecten>test
random(-10) = -1
C:\Users\Bart\LazarusProjecten>test
random(-10) = -4

Maybe my understanding of English ("strictly less than") is not
correct, so I ask here before posting as a bugreport.

Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Bug in documentation for Random?

2017-04-05 Thread Bart
Fun fact: TP's random used an unsigned parameter (word), so no ambiguity there.

Random (function)
 --
Returns a random number.

 Declaration:
 function Random [ ( Range: Word) ]: < Same type as parameter >;

Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] mirror freepascal.stack.nl down

2017-04-05 Thread Marco van de Voort

One of the FPC mirrors "freepascal.stack.nl" is currently being migrated to
a new vm. I hope access will be restored within hours.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Bug in documentation for Random?

2017-04-05 Thread Bart
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Random

"random returns a random number between 0 and abs(num-1)"

IIUC, then Random() shoud always return a positive number.

Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Bug in documentation for Random?

2017-04-05 Thread Santiago A.
El 05/04/2017 a las 18:09, Bart escribió:
> http://www.freepascal.org/docs-html/current/rtl/system/random.html
>
> "Random returns a random number larger or equal to 0 and strictly less than L"
>
> However random(a negative number) returns a number <= 0 and > L
>
>
> program r;
> begin
>   randomize;
>   writeln('Random(-10) = ',Random(-10));
> end.
>
> C:\Users\Bart\LazarusProjecten>test
> random(-10) = -1
> C:\Users\Bart\LazarusProjecten>test
> random(-10) = -4
>
> Maybe my understanding of English ("strictly less than") is not
> correct, so I ask here before posting as a bugreport.

I've never used negative values, so this is just a guess:
random(+10)
will output numbres 0..9

random(-10)
will output numbres -9..0

so, it is equivalent to
-random(10)

-- 
Saludos

Santi
s...@ciberpiula.net

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Array clearing

2017-04-05 Thread Jonas Maebe

On 05/04/17 04:49, Ryan Joseph wrote:

Yeah after all this talk, I’m going to use array[0..0, 0..0, 0..0] and allocate 
the memory myself to avoid overhead and confusion. Thanks for explaining 
everything to me but this time going low level makes the most sense.


Then you lose the ability to turn on range checking in your program, 
since any access with an index greater than 0 will cause an error.



Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Bug in documentation for Random?

2017-04-05 Thread Ched

Usualy "non-negative", not positive !


Cheers, Ched'


Le 05.04.2017 à 16:55, Bart a écrit :

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Random

"random returns a random number between 0 and abs(num-1)"

IIUC, then Random() shoud always return a positive number.

Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal