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


Groups > comp.lang.javascript > #27121

Re: Bignumb multiplication

Newsgroups comp.lang.javascript
Date 2015-03-24 04:21 -0700
References <8032d59d-caab-4553-b8ca-834ea25c25de@googlegroups.com>
Message-ID <f2cf552c-c6f0-4473-9d47-9eaee1ecedd8@googlegroups.com> (permalink)
Subject Re: Bignumb multiplication
From jonas.thornvall@gmail.com

Show all headers | View raw


Den tisdag 24 mars 2015 kl. 12:13:46 UTC+1 skrev jonas.t...@gmail.com:
> 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;}
> }
> }

Still missing a case.

Back to comp.lang.javascript | Previous | Next — Previous 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