0

The unsigned long long type doesn't work as expected for me. Here's my simple code:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
    unsigned long long a = 2932306814;
    printf("a = %d\n", a);
    return EXIT_SUCCESS;
}

I get the following output:

a = -1362660482

The used gcc was installed as part of mingw and has version 4.8.1.

Danny Lo
  • 1,553
  • 4
  • 26
  • 48

1 Answers1

3

You are not printing the number correctly. %d specifier is for an int. Use the specifier %llu for an unsigned long long.

Change to:

printf("a = %llu\n", a);
nnn
  • 3,980
  • 1
  • 13
  • 17