Skip to main content
relaxe
Associate III
January 7, 2009
Question

Binary representation in IAR

  • January 7, 2009
  • 5 replies
  • 1493 views
Posted on January 07, 2009 at 10:20

Binary representation in IAR

    This topic has been closed for replies.

    5 replies

    relaxe
    relaxeAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Using IAR 5.20:

    Normal representation of:

    Decimal:

    i = 30;

    Hex:

    i = 0x1E;

    How do you write binary variables????

    Binary:

    i = ?????????????????????

    Please!

    -Relaxe

    st3
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    The standard 'C' programming language provides no way to write binary constants.

    If IAR have provided some extension to allow this, then it will be in their Documentaion - but this is quite uncommon. :(

    Given that anything you might find is totally non-standard and, therefore, totally non-portable, I suggest that you just stick to Hex.

    picguy
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    In the assembler use 01010b and the like

    In C/C++ I found nothing in the docs. Given that plus what I tried you may need to use standard C/C++ hex 0xABC or octal 0123.

    paulsmitton9
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    You can use a macro. See:

    http://cprog.tomsweb.net/binconst.txt

    stevemelnikoff9
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:58

    Some compilers allow binary data to be represented by starting the value with ''0b'', e.g.: 0b00000000.

    Steve.