Hi all
It has been a long time... :)
Hey does any one know if it is possible to add prefix before a number to represent binary
For example
unsigned char a = 0xF0; This is for hexadecimal
Is there a similar representation for binary and octal?
I already tried
unsigned char a = 0b11110000;
It is possible in MPLAB but not with gcc on linux.
Any solutions...???
It has been a long time... :)
Hey does any one know if it is possible to add prefix before a number to represent binary
For example
unsigned char a = 0xF0; This is for hexadecimal
Is there a similar representation for binary and octal?
I already tried
unsigned char a = 0b11110000;
It is possible in MPLAB but not with gcc on linux.
Any solutions...???
Sorry my mistake it works on linux with gcc too... :)
ReplyDeleteBut what about octal....???
Does any one know??
Yes it is possible ... We have to just give one 0 before the octal number which we are assigning.
ReplyDeleteFor example:
#include
int main(void){
unsigned char a = 0171;
printf("%c\n", a);
printf("%d\n", a);
return 0;
}
The output of this program is
y
121
y represents the character value of 121, which is decimal value of octal 171.
Good man thanks...
ReplyDeleteThis is what happens if u don't code for long time... :(