0

I wanted to understand the difference between the following two definitions

unsigned long long id = 0x0FULL; //should be correct
unsigned int store = 0X0FULL;  // ?? Can this be done 

printf("id is : 0x%llx store is : 0x%x\n",id,store);

An output for the the two variables returns the same value

id is : 0xf store is : 0xf
cmidi
  • 1,880
  • 3
  • 20
  • 35

2 Answers2

7

It's just a coincidence that it happens to spell out a word. The ULL suffix means you've got an unsigned long long literal, and 0xF or 0x0F you already know: that's 15, except expressed in hexadecimal.

  • You mean 15 in decimal right? Also I get that 0xFULL is a `ULL` literal so you mean would it be wrong to do something like `unsigned int store = 0X0FULL;` – cmidi Feb 09 '15 at 16:51
  • 2
    @cmidi I mean that's decimal 15, expressed in hexadecimal. I see I worded it a bit confusingly. `unsigned int store = 0x0FULL;` is valid but weird. It's valid because there is an implicit conversion between any two integral types, including from `unsigned long long` to `unsigned int`. It's weird because if you want an `unsigned int`, why would you use an `ULL` suffix? –  Feb 09 '15 at 16:55
  • I was just trying to chase down a problem in a open source library code, which has something similar in the code – cmidi Feb 09 '15 at 17:03
5

0x0f is an int with the value 15.

0x0full is an unsigned long long with the value 15.

fredoverflow
  • 256,549
  • 94
  • 388
  • 662