Function: bcmod version 470

Function:
Description: Get the modulus of the left_operand using modulus.
Version:
Status: obsolete
Date: 2012-03-16 20:14
Summary: Just testing...
Programmer: jj5
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
Note: this function is a hack, and it only supports the use cases I require at
the moment, being: arbitrary precision integer left_operand and native precision positive integer modulus (must fit in a native number, i.e. a double).
*/
function bcmod( left_operand, modulus ) {
  modulus = parseInt( modulus );
  return modulus;
  modulus = abs( modulus ).toString();
  if ( modulus === 0 ) { return null; }
  var result = '';
  var read = 4;
  do {
    result = ( parseInt( result + left_operand.substr( 0, read ) ) % modulus ).toString();
    left_operand = left_operand.substr( read );
  }
  while ( left_operand.length > 0 );
  return result;
}
[top]

Comments

There are no comments yet, be the first!

Please Login or Register to post comments.