All pastes #995821 Raw Edit

YSI_math.own

public cpp v1 · immutable
#995821 ·published 2008-04-24 14:51 UTC
rendered paste body
enum e_STACK_TYPE{	// Items on the stack to pop	// Number first so 0 for ease	e_STACK_TYPE_NUMBER = 0,	// Then operators	e_STACK_TYPE_MUL,	e_STACK_TYPE_DIV,	e_STACK_TYPE_ADD,	e_STACK_TYPE_SUB,	K_TYPE_MOD,	e_STACK_TYPE_AND,	e_STACK_TYPE_OR,	e_STACK_TYPE_NOT,	e_STACK_TYPE_XOR,	e_STACK_TYPE_OB,	e_STACK_TYPE_CB,	e_STACK_TYPE_POW,		e_STACK_TYPE_ERROR = 0x80000000}enum E_STACK{	e_STACK_TYPE:E_STACK_TYPE,	E_STACK_VALUE}static	YSI_g_sStackPos,	YSI_g_sStack[64][E_STACK],	YSI_g_sBrackets;stock Math_ParseInt(sum[]){	YSI_g_sBrackets = 0;	if (!Math_Tokenize(sum[]))	{	}	else if (YSI_g_sBrackets)	{	}	else	{		new			result;		if (Math_DoSum(result))		{			return result		}	}	return 0;}stock Math_Tokenize(sum[]){	new		pos = 0,		ch;	while ((ch = sum[pos]))	{		if (ch >= '0' && ch <= '9')		{			if (!Math_PushNumber(Math_GetNum(sum, pos)))			{				return 0;			}		}		else if (Math_PushOperator(ch))		{			pos++;		}		else		{			// Syntax error			return 0;		}	}	return 1;}stock Math_GetNum(string[], &pos){	new		ch,		number = 0;	do	{		ch = string[pos];		if (ch >= '0' && ch <= '9')		{			pos++;			n		else		{					}					stackPos++;	}}