How to increase range in C++?

Hello, everyone.
I thought a lot about increasing the range of integer manually (The long long int is not enough). But I don't find a way. I tried to use BIT-FIELDS, but I can't find a way to assign the value. See this please-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <bits/stdc++.h>
using namespace std;

struct A{
    unsigned a : 9999999;
};

int main()
{
    A range;
    range.a = 9999999999999999;

    cout << range.a; // printing garbage value

    return 0;
}

It is printing some stupid value!
Can I increase the range this way? Or is there any other way that I can manually elevate the range like BigInteger in Java? There is of course a way I guess.
Last edited on
Can I increase the range this way?
No. Width of bitfield cannot exceed width of underlying type. http://puu.sh/iTPGy/dc176c78be.png
Or is there any other way that I can manually elevate the range like BigInteger in Java?
Use big integer library.
https://www.google.com/search?q=BigInteger+C%2B%2B
Last edited on
Thanks, I'll see what I can learn... Maybe I need to use string to hold the value and then perform operations on them. Cool stuff, really is!
Topic archived. No new replies allowed.