943,518 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 5886
  • C RSS
Nov 16th, 2007
0

representing binary values

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
desijays is offline Offline
21 posts
since Mar 2007
Nov 16th, 2007
0

Re: representing binary values

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC