procedure irmult(i: integer; var x: hreal);
var
  iabs,n: integer;
  j,m: integer32;
begin { irmult }
  with x do if si<>0 then begin
    if (i=0) then si:=0
    else begin
      if i>0 then iabs:=i
      else begin
        iabs:=-i;
        si:=-si;
      end;
      if iabs>topint then writeln('irmult: error - integer out of range');
      m:=iabs*ma[0];
      if m+iabs<10000 then begin
        j:=0;
        for n:=hdim downto 1 do begin
          j:=iabs*ma[n]+j;
          ma[n]:=j mod 10000;
          j:=j div 10000;      
        end;
        ma[0]:=m+j;
        trunc:=false;
      end
      else begin
        m:=iabs*ma[hdim];
        j:=m div 10000;
        m:=m mod 10000; 
        for n:=hdim-1 downto 0 do begin
          j:=iabs*ma[n]+j;
          ma[n+1]:=j mod 10000;
          j:=j div 10000;      
        end;
        if j>0 then begin
          ma[0]:=j;
          ex:=ex+1;
          if ex>exmax then overflow:=true;
          trunc:=(m>0);
        end
        else begin
          for n:=0 to hdim-1 do ma[n]:=ma[n+1];
          ma[hdim]:=m;
          trunc:=false;
        end;
      end;
    end;
  end;
end { irmult };

