Re: [fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-24 Thread Jonas Maebe
On 24/05/17 09:35, Thaddy de Koning wrote: The implementation is _*not *_undefined for negative values,_unless you say that you define it as undefined_. That is exactly what "undefined" means: the implementation was not designed to handle such values, so whatever you get as a result is

Re: [fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-24 Thread Thaddy de Koning
Jonas, sorry for the late response: The implementation is _*not *_undefined for negative values,_unless you say that you define it as undefined_. Because you seem to have implemented it or most of it. It renders a mathematical comparable distribution in the negative to the positive values.

Re: [fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-24 Thread Thaddy de Koning
Of course 64 and 32 bit are the sizes, not the platform! That may not be clear. On 5/24/2017 9:35 AM, Thaddy de Koning wrote: Jonas, sorry for the late response: The implementation is _*not *_undefined for negative values,_unless you say that you define it as undefined_. Because you seem

Re: [fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-20 Thread Bart
On 5/20/17, Jonas Maebe wrote: > random(x) is undefined for negative parameters. It should have had an > unsigned parameter, like in Turbo Pascal (where it is word). Delphi > defines it as always returning a positive value, but I don't know what > happens if you pass a

Re: [fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-20 Thread Jonas Maebe
On 20/05/17 15:38, José Mejuto wrote: At least in 3.0 (trunk not tested as I don't have it compiled) the first and second random numbers are always the same value, so: That is unrelated to this thread, but has been fixed in FPC 3.0.2. Jonas ___

Re: [fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-20 Thread Mark Morgan Lloyd
On 20/05/17 13:00, Martin Schreiber wrote: Hi, FPC fixes_3_0, Linux X86:"var i1: int32;begin for i1:= 0 to 5 do begin writeln(random(int32(-16))); end; writeln('*'); for i1:= 0 to 5 do begin writeln(random(int64(-16))); end;end;" produces"-9-9-11-13-10-13*395468"Is

Re: [fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-20 Thread Jonas Maebe
On 20/05/17 14:36, Martin Schreiber wrote: Is this intended? If not, which one is correct? random(x) is undefined for negative parameters. It should have had an unsigned parameter, like in Turbo Pascal (where it is word). Delphi defines it as always returning a positive value, but I don't

[fpc-devel] Different results of random(int32) and random(int64) for negative limit value

2017-05-20 Thread Martin Schreiber
Hi, FPC fixes_3_0, Linux X86: " var i1: int32; begin for i1:= 0 to 5 do begin writeln(random(int32(-16))); end; writeln('*'); for i1:= 0 to 5 do begin writeln(random(int64(-16))); end; end; " produces " -9 -9 -11 -13 -10 -13 * 3 9 5 4 6 8 " Is this intended? If