This commit is contained in:
Ivan Bondarev 2023-07-02 19:47:05 +02:00
commit 7c5ba9f83a
11 changed files with 43 additions and 13 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "9";
public const string Build = "0";
public const string Revision = "3299";
public const string Revision = "3305";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=9
%REVISION%=3299
%REVISION%=3305
%COREVERSION%=0
%MAJOR%=3

View file

@ -1,7 +1,5 @@
uses GraphWPF;
function RandomReal(a,b: real): real := Random*(b-a)+a;
type
BallInfo = auto class
x,y,r,dx,dy: real;

View file

@ -2,8 +2,6 @@
const vmax = 50;
function RandomReal(a,b: real): real := Random*(b-a)+a;
type
BallInfo = auto class
x,y,r,vx,vy: real;

View file

@ -1 +1 @@
3.9.0.3299
3.9.0.3305

View file

@ -1 +1 @@
!define VERSION '3.9.0.3299'
!define VERSION '3.9.0.3305'

View file

@ -1700,6 +1700,8 @@ function Random(maxValue: real): real;
function Random(a, b: integer): integer;
/// Возвращает случайное вещественное в диапазоне [a,b)
function Random(a, b: real): real;
/// Возвращает случайное вещественное в диапазоне [a,b] c количеством значащих цифр после точки, равным digits
function RandomReal(a, b: real; digits: integer := -1): real;
/// Возвращает случайный символ в диапазоне от a до b
function Random(a, b: char): char;
/// Возвращает случайное целое в диапазоне
@ -8509,6 +8511,29 @@ begin
Result := a + Random()*(b-a);
end;
function RandomReal(a, b: real; digits: integer): real;
begin
if digits<0 then
Result := Random(a,b)
else begin
// Бывают некорректные данные. Например, найти точку с 2 знаками на [2.736, 2.737]. Тогда возвращать a скажем
var step := 1/10**digits;
Result := Round(Random(a,b),digits);
if Result < a then
begin
Result += step;
if Result > b then
Result := b
end
else if Result > b then
begin
Result -= step;
if Result < a then
Result := a;
end;
end;
end;
function Random(diap: IntRange): integer := Random(diap.Low,diap.High);
function Random(diap: RealRange): real := Random(diap.Low,diap.High);
function Random(diap: CharRange): char := Random(diap.Low,diap.High);

View file

@ -1,7 +1,5 @@
uses GraphWPF;
//function RandomReal(a,b: real): real := Random*(b-a)+a;
type
BallInfo = auto class
x,y,r,dx,dy: real;

View file

@ -571,8 +571,10 @@ namespace PascalABCCompiler.TreeRealization
implements = false;
// Цикл по всем реализуемым интерфейсам. А если tnode сам является интерфейсом?
var ImplementingInterfaces = tnode.ImplementingInterfaces.ToList();
if (tnode.IsInterface)
ImplementingInterfaces.Add(tnode);
// Из-за этой строки возникла ошибка https://github.com/pascalabcnet/pascalabcnet/issues/2872
// Но без этой строчки не работает преобразование sequence of Student к sequence of Person и sequence of object
//if (tnode.IsInterface)
// ImplementingInterfaces.Add(tnode);
foreach (var interf in ImplementingInterfaces)
{
var ctn = interf as compiled_type_node;

View file

@ -48,6 +48,8 @@ function Random(n: integer): integer;
function Random: real;
/// Возвращает случайное вещественное в диапазоне [a,b)
function Random(a, b: real): real;
/// Возвращает случайное вещественное в диапазоне [a,b] c количеством значащих цифр после точки, равным digits
function RandomReal(a, b: real; digits: integer := 1): real;
/// Возвращает случайный символ в диапазоне от a до b
function Random(a, b: char): char;
/// Возвращает случайное целое в диапазоне
@ -1029,6 +1031,13 @@ begin
InputList.Add(Result);
end;
function RandomReal(a, b: real; digits: integer): real;
begin
Result := PABCSystem.RandomReal(a, b, digits);
if IsPT then exit;
InputList.Add(Result);
end;
/// Возвращает случайное целое в диапазоне
function Random(diap: IntRange): integer;
begin

View file

@ -1701,7 +1701,7 @@ function Random(a, b: integer): integer;
/// Возвращает случайное вещественное в диапазоне [a,b)
function Random(a, b: real): real;
/// Возвращает случайное вещественное в диапазоне [a,b] c количеством значащих цифр после точки, равным digits
function RandomReal(a, b: real; digits: integer := 1): real;
function RandomReal(a, b: real; digits: integer := -1): real;
/// Возвращает случайный символ в диапазоне от a до b
function Random(a, b: char): char;
/// Возвращает случайное целое в диапазоне