DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   representing binary values (http://www.daniweb.com/forums/thread96959.html)

desijays Nov 16th, 2007 1:39 am
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?

Salem Nov 16th, 2007 4:16 am
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.


All times are GMT -4. The time now is 3:36 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC