* fixed qword division

This commit is contained in:
florian 1999-06-28 22:25:25 +00:00
parent d39372ee23
commit e0e9f4481e

View File

@ -56,17 +56,17 @@
count_leading_zeros:=r; count_leading_zeros:=r;
end; end;
function divqword(z,n : qword) : qword;[public,alias: 'FPC_DIV_QWORD']; function divqword(n,z : qword) : qword;[public,alias: 'FPC_DIV_QWORD'];
var var
shift,lzz,lzn : longint; shift,lzz,lzn : longint;
one : qword; one : qword;
begin begin
{ we can't write qword direct currently } divqword:=0;
divqword:=divqword xor divqword; one:=1;
tqwordrec(one).high:=0; if n=divqword then
tqwordrec(one).low:=1; runerror(200);
lzz:=count_leading_zeros(z); lzz:=count_leading_zeros(z);
lzn:=count_leading_zeros(n); lzn:=count_leading_zeros(n);
{ if the denominator contains less zeros } { if the denominator contains less zeros }
@ -77,13 +77,13 @@
shift:=lzn-lzz; shift:=lzn-lzz;
n:=n shl shift; n:=n shl shift;
repeat repeat
if z>n then if z>=n then
begin begin
z:=z-n; z:=z-n;
divqword:=divqword+(one shl shift); divqword:=divqword+(one shl shift);
end; end;
dec(shift); dec(shift);
n:=n shr one; n:=n shr 1;
until shift<=0; until shift<=0;
end; end;
@ -261,7 +261,10 @@
{ {
$Log$ $Log$
Revision 1.7 1999-06-25 12:24:44 pierre Revision 1.8 1999-06-28 22:25:25 florian
* fixed qword division
Revision 1.7 1999/06/25 12:24:44 pierre
* qword one was wrong ! * qword one was wrong !
Revision 1.6 1999/06/02 10:13:16 florian Revision 1.6 1999/06/02 10:13:16 florian