OmegaNum.js port for game usage

by Blackcatgame77

JavaScript

//Code snippets and templates from Decimal.js

;(function (globalScope) {
  "use strict";


  // --  EDITABLE DEFAULTS  -- //
  var OmegaNum = {

    // The maximum number of arrows accepted in operation.
    // It will warn and then return Infinity if exceeded.
    // This is to prevent loops to not be breaking, and also to prevent memory leaks.
    // 1000 means operation above {1000} is disallowed.
    // It is not recommended to make this number too big.
    // `OmegaNum.maxArrow = 1000;`
    maxArrow: 1e3,

    // Specify what format is used when serializing for JSON.stringify
    //
    // JSON   0 JSON object
    // STRING 1 String
    serializeMode: 0,

    // Deprecated
    // Level of debug information printed in console
    //
    // NONE   0 Show no information.
    // NORMAL 1 Show operations.
    // ALL    2 Show everything.
    debug: 0
  },


  // -- END OF EDITABLE DEFAULTS -- //


  external = true,

  omegaNumError = "[OmegaNumError] ",
  invalidArgument = omegaNumError + "Invalid argument: ",

  isOmegaNum = /^[-\+]*(Infinity|NaN|(10(\^+|\{[1-9]\d*\})|\(10(\^+|\{[1-9]\d*\})\)\^[1-9]\d* )*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/,

  MAX_SAFE_INTEGER = 9007199254740991,
  MAX_E = Math.log10(MAX_SAFE_INTEGER), //15.954589770191003

  // OmegaNum.prototype object
  P={},
  // OmegaNum static object
  Q={},
  // OmegaNum constants
  R={};

  R.ZERO=0;
  R.ONE=1;
  R.E=Math.E;
  R.LN2=Math.LN2;
  R.LN10=Math.LN10;
  R.LOG2E=Math.LOG2E;
  R.LOG10E=Math.LOG10E;
  R.PI=Math.PI;
  R.SQRT1_2=Math.SQRT1_2;
  R.SQRT2=Math.SQRT2;
  R.MAX_SAFE_INTEGER=MAX_SAFE_INTEGER;
  R.MIN_SAFE_INTEGER=Number.MIN_SAFE_INTEGER;
  R.NaN=Number.NaN;
  R.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY;
  R.POSITIVE_INFINITY=Number.POSITIVE_INFINITY;
  R.E_MAX_SAFE_INTEGER="e"+MAX_SAFE_INTEGER;
  R.EE_MAX_SAFE_INTEGER="ee"+MAX_SAFE_INTEGER;
  R.TETRATED_MAX_SAFE_INTEGER="10^^"+MAX_SAFE_INTEGER;


  // OmegaNum prototype methods

 ...