mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 14:29:25 +02:00
+ helper routine for <int64> mod <in64> added
This commit is contained in:
parent
e22cb380d4
commit
17f8a06883
@ -153,6 +153,39 @@
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function modint64(n,z : int64) : int64;[public,alias: 'FPC_MOD_INT64'];
|
||||||
|
|
||||||
|
var
|
||||||
|
signed : boolean;
|
||||||
|
r,nq,zq : qword;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if n=0 then
|
||||||
|
HandleErrorFrame(200,get_frame);
|
||||||
|
if n<0 then
|
||||||
|
begin
|
||||||
|
nq:=-n;
|
||||||
|
signed:=true;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
signed:=false;
|
||||||
|
nq:=n;
|
||||||
|
end;
|
||||||
|
if z<0 then
|
||||||
|
begin
|
||||||
|
zq:=qword(-z);
|
||||||
|
signed:=not(signed);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
zq:=z;
|
||||||
|
r:=zq mod nq;
|
||||||
|
if signed then
|
||||||
|
modint64:=-int64(r)
|
||||||
|
else
|
||||||
|
modint64:=r;
|
||||||
|
end;
|
||||||
|
|
||||||
{ multiplies two qwords
|
{ multiplies two qwords
|
||||||
the longbool for checkoverflow avoids a misaligned stack
|
the longbool for checkoverflow avoids a misaligned stack
|
||||||
}
|
}
|
||||||
@ -433,7 +466,10 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.18 2000-02-09 16:59:30 peter
|
Revision 1.19 2000-02-09 22:19:24 florian
|
||||||
|
+ helper routine for <int64> mod <in64> added
|
||||||
|
|
||||||
|
Revision 1.18 2000/02/09 16:59:30 peter
|
||||||
* truncated log
|
* truncated log
|
||||||
|
|
||||||
Revision 1.17 2000/01/27 15:43:02 florian
|
Revision 1.17 2000/01/27 15:43:02 florian
|
||||||
@ -447,5 +483,4 @@
|
|||||||
|
|
||||||
Revision 1.14 2000/01/07 16:41:34 daniel
|
Revision 1.14 2000/01/07 16:41:34 daniel
|
||||||
* copyright 2000
|
* copyright 2000
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user