includes/clientside/static/enanomath.js
author Dan
Sat, 15 Mar 2008 00:08:01 -0400
changeset 499 6b7fdd898ba3
parent 436 242353360e37
permissions -rw-r--r--
Fixed some bugs with PostgreSQL and added a word_lcase column to the search_index table because collation is not working under MySQL. TODO: Trigger search index rebuild on upgrade to 1.1.4.

/*
 * EnanoMath, an abstraction layer for big-integer (arbitrary precision)
 * mathematics.
 */

var EnanoMathLayers = {};

// EnanoMath layer: Leemon (frontend to BigInt library by Leemon Baird)

EnanoMathLayers.Leemon = {
  Base: 10,
  PowMod: function(a, b, c)
  {
    a = str2bigInt(a, this.Base);
    b = str2bigInt(b, this.Base);
    c = str2bigInt(c, this.Base);
    var result = powMod(a, b, c);
    result = bigInt2str(result, this.Base);
    return result;
  },
  RandomInt: function(bits)
  {
    var result = randBigInt(bits);
    return bigInt2str(result, this.Base);
  }
}

var EnanoMath = EnanoMathLayers.Leemon;