C ++ Biginteger, what does it mean?

I am puzzled as to why we need BASE = 100000000 and WIDTH = 8. This code is from the book, but I don't understand it.

struct Biginteger {
  static const BASE = 100000000;
  static const WIDTH = 8;

  vector<int> s;
  Biginteger(long long int num = 0) { *this = num; }
  Biginteger operator=(long long num) {
    s.clear();
    do {
      s.push_back(num % BASE);
      num /= BASE;
    } while (mun > 0);
    return *this;
  }

      

+3


source to share


1 answer


Primitive types cannot store arbitrarily large numbers, which is why you need BigInteger. The idea behind BigInteger is to use a sequence of small numbers in primitive types to represent a large number.

C BASE=100000000

and WIDTH=8

you are effectively dividing the original 8 digits by 8 digits.



For example 254325623456546

would be(2543256, 23456546)

You can just change to another (BASE, WIDTH). For example, BASE=10

, WIDTH=1

it means that you keep the number of the figure. For example, there 254325623456546

will be (2, 5, 4, 3, 2, 5, 6, 2, 3, 4, 5, 6, 5, 4, 6)

.

+2


source







All Articles