Skip to main content
Visitor II
May 12, 2003
Question

How to use binary numbers unstead of hex

  • May 12, 2003
  • 6 replies
  • 2002 views
Posted on May 12, 2003 at 08:28

How to use binary numbers unstead of hex

    This topic has been closed for replies.

    6 replies

    us2Author
    Visitor II
    May 8, 2003
    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
    Visitor II
    May 8, 2003
    Posted on May 08, 2003 at 10:39

    In Cosmic and metrowerks you would use:

    unsigned char data;

    data = 0b00000000;

    Regards

    SJO
    us2Author
    Visitor II
    May 8, 2003
    Posted on May 08, 2003 at 11:19

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

    /Ulrich
    Visitor II
    May 8, 2003
    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

    us2Author
    Visitor II
    May 12, 2003
    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
    Visitor II
    May 12, 2003
    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