sercantutar / infint

Arbitrary-Precision Integer Arithmetic
http://sercantutar.github.io/infint/
198 stars 48 forks source link

Can't use bitwise operators on Infint #27

Open dkdonkeykonng opened 3 years ago

dkdonkeykonng commented 3 years ago

Hi, I was wondering if there is anyway to use bitwise operators such as & or << and >> on the InfInt. Here's my code:

#include "InfInt.h"
using namespace std;

int main() 
{
    InfInt num = "123456789012345678901234567890";
    int num2 = num & 1;
    cout << num2;
    return 0;
}

But I get this error: error C2676: binary '&': 'InfInt' does not define this operator or a conversion to a type acceptable to the predefined operator. I'm not sure if this is me or not, but it would really help if I could get them to work. Thanks!

AitzazImtiaz commented 1 year ago

The problem here @dkdonkeykonng is that, you declared int num2, please assign this to InfInt num2, Read the error carefully. You can never relate a InfInt with a Int, this will return the error. Hope it helps you.