6 ms·
What's your justification for saying the second printf "should print 00000000ff000000"?
by josephcsible 5y ago
What's your justification for saying the second printf "should print 00000000ff000000"?
- kelnos 5y agoNot the parent, but my take on it is that you have only unsigned types in all of those signatures, but C goes and promotes the u8 to a signed quantity before doing the shift. What I believe most people would expect is that 0xff would get shifted up, and that's it, but instead you end up with that plus a sign extension to fill out the "new" 32 bits at the top of the 64-bit value.