Exemple #1
0
Exec_stat MCAtan2::eval(MCExecPoint &ep)
{
	if (s1->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL)
	{
		MCeerror->add
		(EE_ATAN2_BADS1, line, pos);
		return ES_ERROR;
	}
	real8 n1 = ep.getnvalue();
	if (s2->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL)
	{
		MCeerror->add
		(EE_ATAN2_BADS2, line, pos);
		return ES_ERROR;
	}
	real8 n2 = ep.getnvalue();
	MCS_seterrno(0);
	ep.setnvalue(atan2(n1, n2));
	if (MCS_geterrno() != 0 || MCS_isnan(ep.getnvalue()))
	{
		MCS_seterrno(0);
		MCeerror->add
		(EE_ATAN2_DOMAIN, line, pos);
		return ES_ERROR;
	}
	return ES_NORMAL;
}
Exemple #2
0
Exec_stat MCLog10::eval(MCExecPoint &ep)
{
	if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL)
	{
		MCeerror->add
		(EE_LOG10_BADSOURCE, line, pos);
		return ES_ERROR;
	}
	MCS_seterrno(0);
	ep.setnvalue(log(ep.getnvalue()) / log(10.0));
	if (MCS_geterrno() != 0 || MCS_isnan(ep.getnvalue()))
	{
		MCS_seterrno(0);
		MCeerror->add
		(EE_LOG10_DOMAIN, line, pos);
		return ES_ERROR;
	}
	return ES_NORMAL;
}
Exemple #3
0
Exec_stat MCExp2::eval(MCExecPoint &ep)
{
	if (source->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL)
	{
		MCeerror->add
		(EE_EXP2_BADSOURCE, line, pos);
		return ES_ERROR;
	}
	MCS_seterrno(0);
	ep.setnvalue(pow(2.0, ep.getnvalue()));
	if (MCS_geterrno() != 0 || MCS_isnan(ep.getnvalue()))
	{
		MCS_seterrno(0);
		MCeerror->add
		(EE_EXP2_DOMAIN, line, pos);
		return ES_ERROR;
	}
	return ES_NORMAL;
}
Exemple #4
0
// MW-2007-07-03: [[ Bug 5123 ]] - Strict array checking modification
//   Here the source can be an array or number so we use 'tona'.
Exec_stat MCMultiply::exec(MCExecPoint &ep)
{
#ifdef /* MCMultiply */ LEGACY_EXEC
	MCVariable *t_dst_var;
	MCVariableValue *t_dst_ref;
	t_dst_ref = NULL;

	if (source->eval(ep) != ES_NORMAL || ep.tona() != ES_NORMAL)
	{
		MCeerror->add(EE_MULTIPLY_BADSOURCE, line, pos);
		return ES_ERROR;
	}

	if (overlap)
		ep . grab();

	if (destvar != NULL && destvar -> evalcontainer(ep, t_dst_var, t_dst_ref) != ES_NORMAL)
	{
		MCeerror->add(EE_MULTIPLY_BADDEST, line, pos);
		return ES_ERROR;
	}

	if (t_dst_ref != NULL && t_dst_ref -> is_array())
	{
		if (t_dst_ref->factorarray(ep, O_TIMES) != ES_NORMAL)
		{
			MCeerror->add(EE_MULTIPLY_BADARRAY, line, pos);
			return ES_ERROR;
		}
		return ES_NORMAL;
	}

	if (ep.getformat() == VF_ARRAY)
	{
		MCeerror->add(EE_MULTIPLY_MISMATCH, line, pos);
		return ES_ERROR;
	}

	// Variable case
	real8 n2 = ep.getnvalue();
	if (t_dst_ref != NULL)
	{
		real8 n1;
		if (!t_dst_ref -> get_as_real(ep, n1))
		{
			MCeerror -> add(EE_MULTIPLY_BADDEST, line, pos);
			return ES_ERROR;
		}
		
		MCS_seterrno(0);
		n1 *= n2;
		if (n1 == MCinfinity || MCS_geterrno() != 0)
		{
			MCS_seterrno(0);
			MCeerror->add(EE_MULTIPLY_RANGE, line, pos);
			return ES_ERROR;
		}
		t_dst_ref -> assign_real(n1);

		if (t_dst_var != NULL)
			t_dst_var -> synchronize(ep, True);

		return ES_NORMAL;
	}

	// Chunk case
	if (dest->eval(ep) != ES_NORMAL || ep.ton() != ES_NORMAL)
	{
		MCeerror->add(EE_MULTIPLY_BADDEST, line, pos);
		return ES_ERROR;
	}
	real8 n1 = ep.getnvalue();
	MCS_seterrno(0);
	n1 *= n2;
	if (n1 == MCinfinity || MCS_geterrno() != 0)
	{
		MCS_seterrno(0);
		MCeerror->add(EE_MULTIPLY_RANGE, line, pos);
		return ES_ERROR;
	}
	ep.setnvalue(n1);
	if (dest->set(ep, PT_INTO) != ES_NORMAL)
	{
		MCeerror->add(EE_MULTIPLY_CANTSET, line, pos);
		return ES_ERROR;
	}

	return ES_NORMAL;
#endif /* MCMultiply */
}