Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27120

Bignumb multiplication

Newsgroups comp.lang.javascript
Date 2015-03-24 04:13 -0700
Message-ID <8032d59d-caab-4553-b8ca-834ea25c25de@googlegroups.com> (permalink)
Subject Bignumb multiplication
From jonas.thornvall@gmail.com

Show all headers | View raw


I think i got the logic correct for a single digit upon multiple digit. So know i just have to save each row of digitmult and add them together in correct way, by inject a zero at start for every new term.



/* MULTIPLY TWO VARIABLES */

function naiveMult(base, arrOne, arrTwo)
{

result = [];
remainder = 0;

for (i = 0; i < lengthTwo; i ++ )
{
tempVal = 0;
tempDig = 0;
j = 0;

while(j < length)
{
tempVal = (arrOne[i] * arrTwo[j]) + remainder;
//document.write(tempVal);
if (tempVal>base){tempDig = tempVal % base; remainder = (tempVal - tempDig) / base; result[j]=tempDig} else {result[j] = tempVal;}

j ++ ;
}
//result[j]=remainder;
if(remainder!=0) {result[j] = remainder;}
}
}

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Bignumb multiplication jonas.thornvall@gmail.com - 2015-03-24 04:13 -0700
  Re: Bignumb multiplication jonas.thornvall@gmail.com - 2015-03-24 04:21 -0700

csiph-web