0

I tried to compute power function using binary exponential method. During which I found some blogs using __uint128_t and I tried to use it but I was getting an error. This is my code

using u64 = uint64_t;

u64 binpower(u64 base, u64 e, u64 mod) {
    u64 result = 1;
    base %= mod;
    while (e) {
        if (e & 1)
            result = (__uint128_t)result * base % mod;
        base = (__uint128_t)base * base % mod;
        e >>= 1;
    }
    return result;
}

I also referred this stating that it was available from GCC >= 4.6. I was using gcc version 6.3.0 (MinGW.org GCC-6.3.0-1).

devumesh
  • 41
  • 4
  • 3
    What is your target environment? One of the answers to your linked questions states "These are only available on 64-bit targets." – Gerhardh Oct 06 '21 at 09:43
  • 2
    C or C++? Do you know which programming language you are coding in? It matters a lot since Mingw uses Microsoft C Runtime, which is non-compliant to C but afaik decent for C++. – Lundin Oct 06 '21 at 09:43
  • 5
    @Gerhardh MinGW.org only has compilers for 32-bit targets, so that's the answer. – ssbssa Oct 06 '21 at 10:29
  • 1
    [mingw is shitty and 32-bit only](https://stackoverflow.com/a/56172701/995714). Use [Mingw-w64](https://www.mingw-w64.org/) instead which is far better – phuclv Oct 06 '21 at 13:03

0 Answers0