need a help on multiply a hundred digit to a hundred digit

need a help on multiply a hundred digit to a hundred digit

ok, and how someone can help you, if you don't specify the entire problem?

I think he wants to have an integer = 0 then add one number at a time until the integer reaches 100? Is that it leaf?

a whole code for multiply in pascal. like:
(1245789632541254789658745123654789582346587985213658234589541236985754698521302102104587036524125968)*(1230214578965874520321014785023698524702654852389502135478950231456987525845256325402135698520324569)
a hundred digit by a hundred digit

probably:) who knows....we wait until he post again!

a whole code for multiply in pascal. like:
(1245789632541254789658745123654789582346587985213658234589541236985754698521302102104587036524125968)*(1230214578965874520321014785023698524702654852389502135478950231456987525845256325402135698520324569)
a hundred digit by a hundred digit

I think he wants to have an integer = 0 then add one number at a time until the integer reaches 100? Is that it leaf?

a whole code for multiply in pascal. like:
(1245789632541254789658745123654789582346587985213658234589541236985754698521302102104587036524125968)*(1230214578965874520321014785023698524702654852389502135478950231456987525845256325402135698520324569)
a hundred digit by a hundred digit

Clear. I think about. Maybe If nobody answers I'll put the code.

Here is the Algorithm. I based on the model of multiplying decimal natural numbers of fixed capacity. And this caused a problem with overflow. So an additional code is needed to control owerflow and save all significant digits in mantissa. The code will work both in Turbo Pascal and Delphi, but in Delphi we can use open arrays and with their help provide the variable length of the type LNumber.

const MaxDigits=10;
type LNumber = array[1..MaxDigits] of byte;
var
  Form2: TForm2;
   A,B,R:LNumber;
procedure Clear(var A:LNumber);
var i:integer;
begin
    for i := MaxDigits downto 1 do A[i]:=0;
end;
Procedure ShiftR(var A: LNumber; Shift:Integer);
var i:Integer;
begin
   {performing right shift}
   for i := MaxDigits downto 1 + Shift do A[i]:=A[i-Shift];
   for i := Shift downto 1 do A[i]:=0;{setting remaining left bytes to zero}
end;
Procedure ShiftL(var A: LNumber; Shift: integer; var BytesOver: integer);
{Shift - Number of bytes to shift}
{BytesOver - Number of bytes exceeded the capacity of LNumber}
var i:Integer;BytesFree,n:integer;
begin
   i:=1;BytesFree:=0;BytesOver:=0;
   {searching for the amount of the leading zeroes}
   while A[i] = 0 do begin i:=i+1;inc(BytesFree);end;
   if BytesFree>Shift then n:=Shift else n:=BytesFree;
   {performing left shift}
   for i := 1 to MaxDigits - n do A[i]:=A[i+n];
   {Setting the remaining right bytes to zero}
   for i := MaxDigits - n + 1 to MaxDigits do A[i]:=0;
   if Shift>BytesFree then BytesOver:=Shift-BytesFree;
   end;
procedure Add(var A, B, R: LNumber; flag: integer);
var i, C, OverFlag:Integer;
{adds A and B and stores the result in R (R:=A+B)}
{add(A,B,A) is equal to A:=A+B}
{flag = 1  overflow }
begin
    OverFlag:=0;
    for i := MaxDigits downto 1 do
    begin
        C:=A[i]+B[i] + OverFlag;
        R[i]:=C mod 10;{the right digit of sum}
        OverFlag := C div 10;{OverFlag = 1 if C>9}
    end;
end;
procedure MulD(var A: LNumber; B: byte;var R: LNumber; var OverFlag: integer);
{Multiplies A by the decimal digit, the product is stored in R}
{OverFlag = 1 overflow}
var i, C:Integer;
begin
     OverFlag:=0;
     for i := MaxDigits downto 1 do
     begin
        C := A[i]*B + OverFlag;
        R[i] := C mod 10; {the right digit of the product}
        OverFlag := C div 10;
     end;
     if OverFlag > 0 then
       begin
          ShiftR(R,1); R[1]:=OverFlag;OverFlag:=1;
       end;
end;
procedure Mul(var A, B, R: LNumber;var Mult:integer);
{Multiplies A by B}
{Mult shows the amount of the truncated digits}
var j, OverFlag, BytesOver, Multiple1, MultipleR:Integer;
    A1, A2:LNumber;
    O:integer;
begin
     Clear(R);
     MultipleR:=0;
     for j := MaxDigits downto 1 do
     if B[j]<>0 then
     begin
        MulD(A, B[j], A1, OverFlag);
        ShiftL(A1, MaxDigits-j, BytesOver);
        Multiple1:=BytesOver+OverFlag;
        ShiftR(R,Multiple1-MultipleR);
        ADD(A1, R, R, OverFlag);
        MultipleR:=Multiple1 + OverFlag;
     end;
     Mult:=MultipleR;
end;
This article has been dead for over six months. Start a new discussion instead.