representing binary values

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2007
Posts: 21
Reputation: desijays is an unknown quantity at this point 
Solved Threads: 1
desijays desijays is offline Offline
Newbie Poster

representing binary values

 
0
  #1
Nov 16th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: representing binary values

 
0
  #2
Nov 16th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC