954,228 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

representing binary values

I know there is a way to represent binary, octal and hex values in C, but how do you do it?

Like, say, if i wanted to specify a hex number i would do,

unsigned char i = 0xFF; or
unsigned char i = 0x32;

What if i wanted to specify the above in binary or octal?

desijays
Newbie Poster
21 posts since Mar 2007
Reputation Points: 10
Solved Threads: 1
 

In octal, it would be
unsigned char foo = 032; // a leading zero.

You can't specify binary constants in standard C, though some compilers designed for small embedded processors do as an extension.

Salem
Posting Sage
Team Colleague
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You