Beispiel #1
0
AOperand< T >::AOperand(std::string const & value, IOperand::eOperandType const & type) throw (AOperand< T >::BadTypeException, AOperand< T >::UnderflowException, AOperand< T >::OverflowException) {

	try {

		long double	d = std::stold(value);

		if (type == IOperand::eOperandType::Int8
			|| type == IOperand::eOperandType::Int16
			|| type == IOperand::eOperandType::Int32) {

			if (d - static_cast< long long >(d) != 0.0) {

				throw (AOperand< T >::BadTypeException());

			}

		}

		switch (type) {

		case IOperand::eOperandType::Int8:

			checkOutOfRange(d, INT8_MIN, INT8_MAX);
			break;

		case IOperand::eOperandType::Int16:

			checkOutOfRange(d, INT16_MIN, INT16_MAX);
			break;

		case IOperand::eOperandType::Int32:

			checkOutOfRange(d, INT32_MIN, INT32_MAX);
			break;

		case IOperand::eOperandType::Float:

			checkOutOfRange(d, FLT_MIN, FLT_MAX);
			break;

		case IOperand::eOperandType::Double:

			checkOutOfRange(d, DBL_MIN, DBL_MAX);
			break;

		}

		this->_value = static_cast< T >(d);

	} catch (std::exception const & e) {

		throw;

	}

}
Beispiel #2
0
int& MatrixNec::getIndexArray(const ptrdiff_t nRow, const ptrdiff_t nCol) const
{
	checkOutOfRange(nRow, nCol);
	return *(_data[nRow] + nCol);
}