32 bits int (unsigned long int) in zdk

Other misc things
Post Reply
inaciose
New member
Posts: 2
Joined: Tue May 14, 2024 6:56 pm

32 bits int (unsigned long int) in zdk

Post by inaciose »

Hi everybody

unsigned long int pos = 0xDEADBEEFLU;
printf("%x\n", pos);

Shows only BEEF

How can I store 0xDEADBEEF in a long int ?

thanks
User avatar
dom
Well known member
Posts: 2141
Joined: Sun Jul 15, 2007 10:01 pm

Re: 32 bits int (unsigned long int) in zdk

Post by dom »

The default size of integer on the z80 is 16 bits, so the %x, %d etc specifiers print 16 bit values.

To print 32 bit integers you need to use %lx %ld etc
inaciose
New member
Posts: 2
Joined: Tue May 14, 2024 6:56 pm

Re: 32 bits int (unsigned long int) in zdk

Post by inaciose »

dom wrote: Tue May 14, 2024 7:42 pm To print 32 bit integers you need to use %lx %ld etc
Thanks
Post Reply