Hi,
--- Ursprüngliche Nachricht --- Von: Jerry Feldman
An: suse-programming-e@suse.com Betreff: Re: [suse-programming-e] Sign-unsigned widening conversion in C Datum: Tue, 28 Mar 2006 13:43:49 -0500
int main() { unsigned int ui = 0xcabcdef2; long long ll_ui = ui; unsigned 32-bit int is assigned to a unsigned 64-bit long long, sign extension does not occur.
unsigned long long ull_ui = ui; unsigned 32-bit int is assigned to a signed 64-bit long long, sign extension does not occur because ui is unsigned.
I guess it should the other way round :), I mean, the first one should be from unsigned 32-bit to signed 64-bit.
Absolutely. First, the rules are in the C standards, (c89 and c99). I wrote a white paper on this a couple of years ago:
http://h21007.www2.hp.com/dspp/files/unprotected/32bitto64bit_whitepaper.pdf Thanks for whitepaper, exactly what I was looking for. Initially I thought that the conversion rules are implementation dependendent. -- Regards, Verdi -- Bis zu 70% Ihrer Onlinekosten sparen: GMX SmartSurfer! Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer