cancel
Showing results for 
Search instead for 
Did you mean: 

How to use binary numbers unstead of hex

us2
Associate II
Posted on May 12, 2003 at 08:28

How to use binary numbers unstead of hex

6 REPLIES 6
us2
Associate II
Posted on May 08, 2003 at 09:53

Hi

How can I (if it is possible) do the following in C with a binary number instead of a hex number?

Code:

unsigned char x;

x= 01010101b; // binary number

/Ulrich
sjo
Associate II
Posted on May 08, 2003 at 10:39

In Cosmic and metrowerks you would use:

unsigned char data;

data = 0b00000000;

Regards

SJO
us2
Associate II
Posted on May 08, 2003 at 11:19

Yes but it does not work. I get an error when compiling: C2704 - Illegal number

/Ulrich
sjo
Associate II
Posted on May 08, 2003 at 16:38

I have tested it in both cosmic and metrowerks with no problems ?

What compiler/version are you using?

You are using 0b00000000 not 00000000b as per your example ?

Regards

SJO

us2
Associate II
Posted on May 12, 2003 at 06:33

Hi again

I am using Metrowerks Codewarrior ver. 4.1 build 0621.

I tried the method you suggested but still the same error.

Regards,

Ulrich
sjo
Associate II
Posted on May 12, 2003 at 08:28

I have checked my version and it is 4.2.5.766

Looks like you need to upgrade.

Regards

SJO