Octal and Hexadecimal not displaying correctly?


#1

Hi

I’m just at the start of theNumbers chapter and when I run…

#include <stdio.h>

int main (int argc, const char * argv[])
{

int x= 25;

printf("x is in decimal %d.\n",x); 
printf("In octal is %o.\n",x);     
printf("In hexadecimal is %x.\n",x); 

return 0;

}

my output is…

This GDB was configured as “x86_64-apple-darwin”.tty /dev/ttys000
[Switching to process 423 thread 0x0]
x is in decimal 25.
In octal is 31. //according to the book this should be 377
In hexadecimal is 19. //and this should be ff
Program ended with exit code: 0

Anyone have any ideas?, maybe I made a typo, I dont see anything…

Thanks

Lenny


#2

Hi Lenny,

int x = 255;

-Francesco


#3

thanks Francesco

typo…typical… :wink:

cheers

lenny