How can I do arithmetic operations between unsigned binary values without converting them to decimal?

57 Views Asked by At

I am a programmer that needs help in understanding this concept. Let me briefly explain my situation.

The maximum signed number you can represent in the programming language I use(C++, for whoever is intersted in knowing) is $2^{63} -1$, which is $9223372036854775807$, the unsigned value, of course, would be $2^{64} -1$, or $(2^{63}) * 2$ = $18446744073709551614$.

However, it would be possible to represent larger values if the data is treated like a binary number, so, without using base 10. My problem is, I can't convert values to decimal to then comfortably do arithmetic operations, because remember, the limitation. So, how exactly do I add two unsigned binary values together? And I promise you, google did not help.

1

There are 1 best solutions below

1
On
#include <iostream>

using namespace std;

int main()
{
    unsigned long long x=9223372036854775807;
    cout << x+x << endl;
    return 0;
}

Output: 18446744073709551614