js/calc.js
/**
	 * @private 
	 * Solves an individual expression contained within parenthesis. 
	 * Used internaly by solveExpression().
	 * 
	 * @param: arguments is automatically passed from String.replace() function in solveExpression() method.
	 * @return A string that is numeric solution to the expression in parenthesis
	 *
	 * */
@private
Solves an individual expression contained within parenthesis.
Used internaly by solveExpression().

@param: arguments is automatically passed from String.replace() function in solveExpression() method.
@return A string that is numeric solution to the expression in parenthesis
@private Solves an individual expression contained within parenthesis . Used internaly by solveExpression () . @param : arguments is automatically passed from String . replace () function in solveExpression () method . @return A string that is numeric solution to the expression in parenthesis
function solveBracket()
	{
		var args = arguments;
		var exp = arguments[0];
		var ops = /[\/\*\+\-\^~]+/g;
		var a = exp.match(ops) || [];
		if (exp.substr(0, 1) != "(")
		{
		}
		else if (a.length == 0)
		{
			exp = exp.replace(/[\(\)]/g, "");
			if (!isString(exp))
				exp = getValueFromOperand(exp).toString();
		}
		else
		{
			exp = exp.replace(/[\(\)]/g, "");
			var regex = /([a-zA-Z0-9~!\.]+)(\^)([a-zA-Z0-9~!\.]+)/g;
			while (exp.indexOf("^") != -1)
			{
				exp = exp.replace(regex, solveSimple);
			}
			regex = /([a-zA-Z0-9~!\.]+)([\*\/])([a-zA-Z0-9~!\.]+)/g;
			while (exp.indexOf("*") != -1 || exp.indexOf("/") != -1)
			{
				exp = exp.replace(regex, solveSimple);
			}
			regex = /([a-zA-Z0-9~!\.]+)([\+-])([a-zA-Z0-9~!\.]+)/g;
			while (exp.indexOf("+") != -1 || exp.indexOf("-") != -1)
			{
				exp = exp.replace(regex, solveSimple);
			}
		}
		return exp;
	}
function solveBracket ( ) { var args = arguments ; var exp = arguments [ 0 ] ; var ops = / [\/\*\+\-\^~]+ / g ; var a = exp . match ( ops ) || [ ] ; if ( exp . substr ( 0 , 1 ) != "(" ) { } else if ( a . length == 0 ) { exp = exp . replace ( / [\(\)] / g , "" ) ; if ( ! isString ( exp ) ) exp = getValueFromOperand ( exp ) . toString ( ) ; } else { exp = exp . replace ( / [\(\)] / g , "" ) ; var regex = / ([a-zA-Z0-9~!\.]+)(\^)([a-zA-Z0-9~!\.]+) / g ; while ( exp . indexOf ( "^" ) != - 1 ) { exp = exp . replace ( regex , solveSimple ) ; } regex = / ([a-zA-Z0-9~!\.]+)([\*\/])([a-zA-Z0-9~!\.]+) / g ; while ( exp . indexOf ( "*" ) != - 1 || exp . indexOf ( "/" ) != - 1 ) { exp = exp . replace ( regex , solveSimple ) ; } regex = / ([a-zA-Z0-9~!\.]+)([\+-])([a-zA-Z0-9~!\.]+) / g ; while ( exp . indexOf ( "+" ) != - 1 || exp . indexOf ( "-" ) != - 1 ) { exp = exp . replace ( regex , solveSimple ) ; } } return exp ; }
@private
 Solves an individual expression contained within parenthesis.
@private Solves an individual expression contained within parenthesis .
//exp = solveFormula(exp); // remove enclosing brackets from string // find a simple expression with operator, one operand on the left, and one operand on the right // this RegExp takes care of ^ operator // example: 4+5*4^3, results in finding first 4^3, then 5*4 in the second while iteration // do while there are no more operators. // function called to replace this expression with a numeric string is solveSimple // find a simple expression with operator, one operand on the left, and one operand on the right // this RegExp takes care of * and / operators // example: 4+5*4*3, results in finding first 5*4, then 20*3 in the second while iteration // do while there are no more operators. // function called to replace this expression with a numeric string is solveSimple // find a simple expression with operator, one operand on the left, and one operand on the right // this RegExp takes care of + and - operators // example: 1+2-4, results in finding first 1+2, then 3-4, in the second while iteration   // do while there are no more operators. // function called to replace this expression with a numeric string is solveSimple