二进制值赋值 [英] Binary values assignment
问题描述
大家好,
我们可以将二进制值分配给整数变量,例如
分配十六进制值???
谢谢,
Sethu
Hi everybody,
Can we assign binary values to an integer variable like
assigning Hexadecimal values???
Thanks,
Sethu
推荐答案
除了这个问题:
int a = 0xef;
而不是这个,我们可以将直接二进制值1110 1111
分配给''a''???
-Sethu
Addition to that question :
int a = 0xef;
instead of this, can we assign the direct binary value 1110 1111
to ''a'' ???
-Sethu
se ***** @ gmail.com 说:
我们可以将二进制值分配给整数变量,例如
分配十六进制值???
Can we assign binary values to an integer variable like
assigning Hexadecimal values???
C不支持以二进制
表示形式表示的数字文字。然而,有可能破解一些东西。
可能最好的方法是简单的,例如:
int a = strtoul(" 11101111", NULL,2);
但是你总是可以这样做:
#define BINARY_8(((((((0
#define O)* 2
#define l)* 2 + 1
int a = BINARY_8 lll O llll; < br $>
-
Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
email:rjh在上述域名中, - www。
C does not provide support for numeric literals expressed in binary
representation. Nevertheless, it is possible to hack something up.
Probably the best way is something simple such as:
int a = strtoul("11101111", NULL, 2);
but you could always do something like:
#define BINARY_8 ((((((((0
#define O )*2
#define l )*2+1
int a = BINARY_8 l l l O l l l l ;
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
se *** **@gmail.com 写道:
se*****@gmail.com wrote:
除了这个问题:
int a = 0xef;
而不是这个,我们可以将直接二进制值1110 1111
分配给''a''???
Addition to that question :
int a = 0xef;
instead of this, can we assign the direct binary value 1110 1111
to ''a'' ???
编号为什么你想要?
[`int a = 0xef;`/ does / initialise-with-the-binary-value-1110_1111`a`。 ]
-
伸出隐藏在网络中的镜像。 - 文艺复兴,/奔跑/
Hewlett-Packard Limited注册号:
注册办事处:Cain Road,Bracknell,Berks RG12 1HN 690597 England >
这篇关于二进制值赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!