18

Assuming I have 2 variables:

uint64_t a = ...

uint32_t b = ...

Will comparing the integers yield the expected results, i.e. (a != b), or (b > a)?

Mysticial
  • 452,826
  • 45
  • 327
  • 325
zer0stimulus
  • 20,576
  • 30
  • 105
  • 139
  • http://stackoverflow.com/questions/6770258/how-do-promotion-rules-work-when-the-signedness-on-either-side-of-a-binary-opera –  Apr 11 '12 at 20:25

2 Answers2

24

No problem. The compiler promotes the 32-bit to 64-bit before the comparison

sizzzzlerz
  • 4,101
  • 3
  • 22
  • 34
8

Short answer - yes. The 'smaller' is converted to bigger one before comparison.

nothrow
  • 15,384
  • 7
  • 54
  • 101