Пример #1
0
 IntT subtract(IntT v)
 {
   int_type remainder = static_cast<int_type>(v % (wrap_val));
   IntT underflow = static_cast<IntT>(-(v / (wrap_val)));
   value_ = static_cast<int_type>(value_ - remainder);
   return calculate_wrap(underflow) * -1;
 }
Пример #2
0
 /*! The sign of the returned value will indicate which direction the 
  * wraps went. Ex: add a negative number and wrapping under could occur,
  * this would be indicated by a negative return value. If wrapping over 
  * took place, a positive value would be returned */
 int_type add(int_type v) 
 {
   int_type remainder = static_cast<int_type>(v % (wrap_val));
   int_type overflow = static_cast<int_type>(v / (wrap_val));
   value_ = static_cast<int_type>(value_ + remainder);
   return calculate_wrap(overflow);
 }
Пример #3
0
 IntT add(IntT v)
 {
   int_type remainder = static_cast<int_type>(v % (wrap_val));
   IntT overflow = static_cast<IntT>(v / (wrap_val));
   value_ = static_cast<int_type>(value_ + remainder);
   return calculate_wrap(overflow);
 }
Пример #4
0
 /*! The sign of the returned value will indicate which direction the
  * wraps went. Ex: subtract a negative number and wrapping over could 
  * occur, this would be indicated by a positive return value. If 
  * wrapping under took place, a negative value would be returned */
 int_type subtract(int_type v) 
 {
   int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
   int_type underflow = static_cast<int_type>(-(v / (wrap_max - wrap_min + 1)));
   value_ = static_cast<int_type>(value_ - remainder);
   return calculate_wrap(underflow);
 }