mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 07:39:25 +02:00
* patch by Rika: Perform 32-bit random if the bound fits into 32 bits at runtime, resolves #40171
This commit is contained in:
parent
62c24b3756
commit
15f29b8fa0
@ -739,6 +739,14 @@ var
|
||||
q, bd, ad, bc, ac: qword;
|
||||
carry: qword;
|
||||
begin
|
||||
if (l>=Low(int32)) and (l<=High(int32)) then
|
||||
begin
|
||||
{ random(longint(l)), inlined. This makes random(NativeType) on 64-bit platforms match 32-bit when possible. }
|
||||
if (l < 0) then
|
||||
inc(l);
|
||||
exit(longint(int64(system.random(high(int32)))*l shr 32));
|
||||
end;
|
||||
|
||||
if (l < 0) then
|
||||
begin
|
||||
inc(l);
|
||||
|
Loading…
Reference in New Issue
Block a user