Advertisement

syntax for defining a binary number?

Started by December 23, 2002 02:37 AM
2 comments, last by billybob 21 years, 10 months ago
sorry for the braindead question, but its very hard to google for this because i don''t know what ot search for. how do you define a binary number? like this:

static const unsigned char Test[8] = 
{
	00000001b,
	00000010b,
	00000100b,
	00001000b,
	00010000b,
	00100000b,
	01000000b,
	10000000b,
};
 
but it doesn''t like that, i tried it with ''0x'' on the front, but it says its truncating, so i think its wrong.
You can''t. Write in hexadecimal form instead - it''s very easy to convert between binary and hexadecimal representations, after all.
Advertisement
If the binary numbers you''re trying to represent are powers of 2, you can also simplify things and make them more clear by using the bitshift operator.

static const unsigned char Test[8] = {	1,	1 << 1,	1 << 2,	1 << 3,	1 << 4,	1 << 5,	1 << 6,	1 << 7,}; 


Don''t listen to me. I''ve had too much coffee.
oh, ok thanks

This topic is closed to new replies.

Advertisement