This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Coding a binary data

Hello,

I just want to code a binary data in C.
I mean hera representation is "0x5F", the decimal representation is simply "156" but what is the decimal representation.
I tried 0b010010101 but it doesn't work

Many thanks

Sébastien

Parents
  • The ANSI 'C' language does have a binary data notation.

    I suppose you could do something with the preprocessor if it's really important to you; eg,

    #define B_0000_0000 0x00
    #define B_0000_0001 0x01
    #define B_0000_0010 0x02
    #define B_0000_0011 0x03
    #define B_0000_0100 0x04
    
    etc
    
    #define B_1111_1101 0xfd
    #define B_1111_1110 0xfe
    #define B_1111_1111 0xff

    you could easily generate that in Excel, or write a little program, or something

Reply
  • The ANSI 'C' language does have a binary data notation.

    I suppose you could do something with the preprocessor if it's really important to you; eg,

    #define B_0000_0000 0x00
    #define B_0000_0001 0x01
    #define B_0000_0010 0x02
    #define B_0000_0011 0x03
    #define B_0000_0100 0x04
    
    etc
    
    #define B_1111_1101 0xfd
    #define B_1111_1110 0xfe
    #define B_1111_1111 0xff

    you could easily generate that in Excel, or write a little program, or something

Children