当前位置: 首页>>代码示例>>C++>>正文


C++ ExprResult::IsInt方法代码示例

本文整理汇总了C++中ExprResult::IsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ ExprResult::IsInt方法的具体用法?C++ ExprResult::IsInt怎么用?C++ ExprResult::IsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExprResult的用法示例。


在下文中一共展示了ExprResult::IsInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: result

//						==================
ExprResult				AddExpression::Add
//						==================
(
	ExprResult&			left,
	ExprResult&			right
) const
{
	// Create a result, and initialise its status as undefined.
	ExprResult result( m_strPrecision );
	result.SetStatus( ExprResult::UNDEF_STATUS );

	// Convert any possible UNSPECIFIED operand.
	left.ConvertFromUnspecified();
	right.ConvertFromUnspecified();

	// Both operands must now have arithmetic types; check if either
	// operand has the type FLOAT.
	if ( left.IsFloat() || right.IsFloat() )
	{
		// Convert both to FLOAT.
		left.ConvertToFloat();
		right.ConvertToFloat();
	}

	// Get the numerical values of the operands.
	double* pNumValLeft  = left.GetNumValue();
	double* pNumValRight = right.GetNumValue();

	// Check if the numerical values exist; i.e. check if no
	// null pointers were returned.
	if ( pNumValLeft != 0 && pNumValRight != 0 )
	{
		// Calculate the numerical value of the result by adding
		// the numerical values of the operands.
		double dlNumVal = (*pNumValLeft) + (*pNumValRight);

		// Since both operands now have the same type, check the type
		// of the left operand to check if both have type INT.
		if ( left.IsInt() )
		{
			// Take as value of the result the conversion of its
			// numerical value to a string; not using exponential
			// notation, and with a precision of 0. Then, set the
			// result type to INT.
			result.SetValue( DoubleAsIntToStr( dlNumVal ) );
			result.SetType( ExprResult::INT );
		}
		else
		{
			// Take as value of the result the conversion of its
			// numerical value to a string, using a precision of
			// ADDPRECISION. Then, set the result type to FLOAT.
			result.SetValue( DoubleToStr( dlNumVal, ADDPRECISION ) );
			result.SetType( ExprResult::FLOAT );
		}

		// Set the result status to OK.
		result.SetStatus( ExprResult::OK );
	}
	else
	{
		// Although the operands were of arithmetic type, no mumerical
		// value could be determined; internal error.
		result.SetStatus( ExprResult::INTERNAL_ERROR );
	}

	return result;
}
开发者ID:CGI-TestFrame,项目名称:TestFrameEngine,代码行数:69,代码来源:AddExpression.cpp


注:本文中的ExprResult::IsInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。