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
  • 464,885
  • 45
  • 335
  • 332
zer0stimulus
  • 22,306
  • 30
  • 110
  • 141
  • 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

25

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

sizzzzlerz
  • 4,277
  • 3
  • 27
  • 35
8

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

nothrow
  • 15,882
  • 9
  • 57
  • 104