mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 19:09:16 +02:00
* more overloads for Math.Min/Max, resolves #36161
git-svn-id: trunk@43366 -
This commit is contained in:
parent
faee789507
commit
5ead23513d
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -17849,6 +17849,7 @@ tests/webtbs/tw36013.pp svneol=native#text/pascal
|
|||||||
tests/webtbs/tw3612.pp svneol=native#text/plain
|
tests/webtbs/tw3612.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw36156.pp svneol=native#text/plain
|
tests/webtbs/tw36156.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw36157.pp svneol=native#text/plain
|
tests/webtbs/tw36157.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw36161.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw3617.pp svneol=native#text/plain
|
tests/webtbs/tw3617.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3619.pp svneol=native#text/plain
|
tests/webtbs/tw3619.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw36196.pp svneol=native#text/pascal
|
tests/webtbs/tw36196.pp svneol=native#text/pascal
|
||||||
|
@ -167,6 +167,10 @@ function Min(a, b: Int64): Int64;inline; overload;
|
|||||||
function Max(a, b: Int64): Int64;inline; overload;
|
function Max(a, b: Int64): Int64;inline; overload;
|
||||||
function Min(a, b: QWord): QWord;inline; overload;
|
function Min(a, b: QWord): QWord;inline; overload;
|
||||||
function Max(a, b: QWord): QWord;inline; overload;
|
function Max(a, b: QWord): QWord;inline; overload;
|
||||||
|
function Min(a: Int64; b: Qword): Int64;inline; overload;
|
||||||
|
function Min(a: Qword; b: Int64): Int64;inline; overload;
|
||||||
|
function Max(a: Int64; b: Qword): QWord;inline; overload;
|
||||||
|
function Max(a: Qword; b: Int64): QWord;inline; overload;
|
||||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||||
function Min(a, b: Single): Single;inline; overload;
|
function Min(a, b: Single): Single;inline; overload;
|
||||||
function Max(a, b: Single): Single;inline; overload;
|
function Max(a, b: Single): Single;inline; overload;
|
||||||
@ -2075,6 +2079,39 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{$ifdef FPC_HAS_TYPE_SINGLE}
|
{$ifdef FPC_HAS_TYPE_SINGLE}
|
||||||
|
|
||||||
|
function Min(a: Int64; b: Qword): Int64;inline;
|
||||||
|
begin
|
||||||
|
if a<0 then
|
||||||
|
Result:=a
|
||||||
|
else
|
||||||
|
Result:=Min(QWord(a),b);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Min(a: Qword; b: Int64): Int64;inline;
|
||||||
|
begin
|
||||||
|
if b<0 then
|
||||||
|
Result:=b
|
||||||
|
else
|
||||||
|
Result:=Min(a,QWord(b));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Max(a: Int64; b: Qword): QWord;inline;
|
||||||
|
begin
|
||||||
|
if a<0 then
|
||||||
|
Result:=b
|
||||||
|
else
|
||||||
|
Result:=Max(QWord(a),b);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Max(a: Qword; b: Int64): QWord;inline;
|
||||||
|
begin
|
||||||
|
if b<0 then
|
||||||
|
Result:=a
|
||||||
|
else
|
||||||
|
Result:=Max(a,QWord(b));
|
||||||
|
end;
|
||||||
|
|
||||||
function Min(a, b: Single): Single;inline;
|
function Min(a, b: Single): Single;inline;
|
||||||
begin
|
begin
|
||||||
if a < b then
|
if a < b then
|
||||||
|
40
tests/webtbs/tw36161.pp
Normal file
40
tests/webtbs/tw36161.pp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{ %OPT=-O1 }
|
||||||
|
program Project1;
|
||||||
|
uses Math;
|
||||||
|
var
|
||||||
|
t: Qword;
|
||||||
|
i: int64;
|
||||||
|
begin
|
||||||
|
i:=-12345687;
|
||||||
|
t:=QWord($a000000000000000);
|
||||||
|
if Min(sizeof(t), t)<>sizeof(t) then
|
||||||
|
halt(1);
|
||||||
|
if Min(t, sizeof(t))<>sizeof(t) then
|
||||||
|
halt(2);
|
||||||
|
if Min(t, i)<>i then
|
||||||
|
halt(3);
|
||||||
|
if Min(i, t)<>i then
|
||||||
|
halt(4);
|
||||||
|
if Min(sizeof(t),sizeof(t))<>sizeof(t) then
|
||||||
|
halt(5);
|
||||||
|
if Min(t,t)<>t then
|
||||||
|
halt(6);
|
||||||
|
if Min(i,i)<>i then
|
||||||
|
halt(7);
|
||||||
|
|
||||||
|
if Max(sizeof(t), t)<>t then
|
||||||
|
halt(11);
|
||||||
|
if Max(t, sizeof(t))<>t then
|
||||||
|
halt(12);
|
||||||
|
if Max(i, t)<>t then
|
||||||
|
halt(13);
|
||||||
|
if Max(t, i)<>t then
|
||||||
|
halt(14);
|
||||||
|
if Max(sizeof(t),sizeof(t))<>sizeof(t) then
|
||||||
|
halt(15);
|
||||||
|
if Max(t,t)<>t then
|
||||||
|
halt(16);
|
||||||
|
if Max(i,i)<>i then
|
||||||
|
halt(17);
|
||||||
|
writeln('ok');
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user