|
发表于 2022-12-29 22:43:48
|
显示全部楼层
本楼为最佳答案
显示的那个颜色并不意味着什么,只是为了方便你看程序
标准没有规定二进制,有的编译器可以使用0b前缀
下面的程序gcc没问题,其他编译器没试过
- sh-5.1$ cat main.c
- #include <stdio.h>
- int main(void) {
- printf("%d\n", 0b10010110);
- return 0;
- }
- sh-5.1$ gcc --version
- gcc (GCC) 12.2.0
- Copyright (C) 2022 Free Software Foundation, Inc.
- This is free software; see the source for copying conditions. There is NO
- warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- sh-5.1$ gcc -g -Wall -o main main.c
- sh-5.1$ ./main
- 150
- sh-5.1$
复制代码
参考
https://blog.csdn.net/nibiewuxuanze/article/details/7842660
https://www.cnblogs.com/Martinium/p/binary_literal.html
|
|