diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index 43a596b..e216a95 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -1501,10 +1501,38 @@ public: /*! * - * convertion method + * convertion methods * */ + + /*! + converting from another type of a Big object + */ + template + uint FromBig(const Big & another) + { + info = another.info; + + if( exponent.FromInt(another.exponent) ) + return 1; + + uint man_len_min = (man < another_man)? man : another_man; + uint i; + + for( i = 0 ; i' to this class + */ + template + Big & operator=(const Big & value) + { + FromBig(value); + + return *this; + } + + + /*! + a constructor for converting from 'Big' to this class + */ + template + Big(const Big & value) + { + FromBig(value); + } + /*! a default constructor diff --git a/ttmath/ttmathparser.h b/ttmath/ttmathparser.h index e0bdc83..dfacefa 100644 --- a/ttmath/ttmathparser.h +++ b/ttmath/ttmathparser.h @@ -1158,6 +1158,35 @@ void BitXor(int sindex, int amount_of_args, ValueType & result) } } + +void Sum(int sindex, int amount_of_args, ValueType & result) +{ + if( amount_of_args == 0 ) + Error( err_improper_amount_of_arguments ); + + result = stack[sindex].value; + + for(int i=1 ; i::BitAnd); InsertFunctionToTable(std::string("bor"), &Parser::BitOr); InsertFunctionToTable(std::string("bxor"), &Parser::BitXor); + InsertFunctionToTable(std::string("sum"), &Parser::Sum); + InsertFunctionToTable(std::string("avg"), &Parser::Avg); }