int main(int argc, char * argv[])
{
	printf("2*4 + 2*1 + 2*7 = %d \n", ComputeExpr(4,1,7));
	printf("2*2 + 2*3 + 2*4 = %d \n", ComputeExpr(2,3,4));
	printf("2*10 + 2*12 + 2*71 = %d \n", ComputeExpr(10,12,71));
	printf("2*28 + 2*123 + 2*40 = %d \n", ComputeExpr(28,123,40));
}
Example #2
0
enum eExprErr ComputeExpression(char *expr, int typ, BigInteger *ExpressionResult)
{
  int retcode;
  valueXused = FALSE;
  stackIndex = 0;
  exprIndex = 0;
  type = typ;
  retcode = ComputeExpr(expr, ExpressionResult);
  if (retcode != 0) { return retcode; }
  if (ExpressionResult[0].nbrLimbs > 33219 / BITS_PER_GROUP + 1)    // 10000/log_10(2) = 33219
  {
    return EXPR_NUMBER_TOO_HIGH;
  }
  if (valueX.nbrLimbs > 0 && valueXused == FALSE)
  {
    return EXPR_VAR_OR_COUNTER_REQUIRED;
  }
  return 0;
}