bignum_helper.h 788 B

12345678910111213141516171819202122
  1. //
  2. // bignum_helper.h
  3. // bigdecimal
  4. //
  5. // Created by Sam Jaffe on 7/4/17.
  6. //
  7. #pragma once
  8. #include <vector>
  9. namespace math { namespace detail {
  10. using data_type = std::vector<int32_t>;
  11. constexpr const int32_t powers[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };
  12. // 1 => GREATER, 0 => EQUAL, -1 => LESS
  13. int compare(data_type const & rhs, data_type const & lhs, size_t offset = 0);
  14. void add(data_type & rhs, data_type const & lhs, size_t offset = 0);
  15. void subtract_nounderflow(data_type & rhs, data_type const & lhs, size_t offset = 0);
  16. void multiply(data_type & rhs, data_type const & lhs, size_t offset = 0);
  17. data_type divide(data_type & remainder, data_type const & divisor);
  18. data_type shift10(data_type const & data, int32_t places);
  19. } }