Can I use a binary literal in C or C++?

前端 未结 19 2437
梦如初夏
梦如初夏 2020-11-22 07:40

I need to work with a binary number.

I tried writing:

const x = 00010000;

But it didn\'t work.

I know that I can use an hex

相关标签:
19条回答
  • 2020-11-22 08:21

    If you are using GCC then you can use a GCC extension (which is included in the C++14 standard) for this:

    int x = 0b00010000;
    
    0 讨论(0)
提交回复
热议问题