Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between 15 and 015? [duplicate]

Tags:

c++

char

output

This might be appear to be a silly/trivial question at first, but when I do this:

char f_gear = 15;

I get the normal output

"☼"

but when I pad it with zeros when i declare it:

char f_gear = 015;

I get weird output makes text look garbled (in one line) and blanks the previous line. When I attempt to see the individual character itself, I get the following:

"  ◘◘@╧S☻ "

What is essentially different? Isn't 15==015?

==EDIT== Stack Overflow changed the text when I posted the question. The output I really saw was a few blank characters.

like image 212
ayane_m Avatar asked Feb 22 '13 04:02

ayane_m


1 Answers

No, 015 refers to octal number. So, 015 in octal is equal to 13 in decimal.

So,

char f_gear = 015;

is equivalent to

char f_gear = 13;
like image 190
RAM Avatar answered Sep 20 '22 13:09

RAM