声明问题。 [英] Declaration Problem.

查看:93
本文介绍了声明问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。


这两个陈述是什么意思?


1)


#define stuff(x)(x>> 3)


2)


#define stuff1(x)(x& 7)

在此先感谢,

Bob

Hello.

What do these two statements mean?

1)

#define stuff(x) (x >> 3)

2)

#define stuff1(x) (x & 7)
Thanks in advance,
Bob

推荐答案

Bob Kensworth写道:
Bob Kensworth wrote:
你好。

这两个陈述是什么意思?

1)

#define stuff(x )(x>>> 3)

2)

#define stuff1(x)(x& 7)

提前致谢,鲍勃
Hello.

What do these two statements mean?

1)

#define stuff(x) (x >> 3)

2)

#define stuff1(x) (x & 7)
Thanks in advance,
Bob




查看C语言参考手册中的位操作

或按位运算符。这两行都是宏。请参阅预处理器指令下的

部分。


第一行定义一个返回参数的宏

右移3个位置(即除以8)。


第二个定义了一个宏,它返回一个值

屏蔽掉参数的3个最低有效位。


-

托马斯马修斯


C ++新闻组欢迎辞:
http://www.slack.net/~shiva/welcome.txt

C ++常见问题: http://www.parashift。 com / c ++ - faq-lite

C常见问题: http://www.eskimo.com/~scs/c-faq/top.html

alt.comp.lang.learn.c -c ++ faq:
http ://www.raos.demon.uk/acllc-c++/faq.html

其他网站:
http://www.josuttis.com - C ++ STL图书馆书籍
http://www.sgi.com/tech/stl - 标准模板库



Look in your C reference manual under "bit manipulation"
or "bitwise operators". Both lines are macros. See the
section under "Preprocessor Directives".

The first line defines a macro that returns the parameter
right shifted 3 places (i.e. divided by 8).

The second one defines a macro which returns a value that
masks off the 3 least significant bits of the parameter.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library


Bob Kensworth写道:
Bob Kensworth wrote:
你好。

这两个陈述是什么意思?

1)

#define stuff(x)(x>> 3)

2)

#define stuff1(x)(x& 7)

提前致谢,
鲍勃
Hello.

What do these two statements mean?

1)

#define stuff(x) (x >> 3)

2)

#define stuff1(x) (x & 7)
Thanks in advance,
Bob




我不确定1.数字2表示执行'逻辑和''操作

使用x和7作为操作数。


这个'逻辑和''操作是在基数2数字系统中的数字上完成的。

(二进制数系统)。七是0000 0111这个二进制(基数2)数字

系统。现在,让我们说我拿了1100 0011并在这两个数字上执行这个'&''操作

。 ---------

这很简单。你所做的只是在虚线下面放一个1,

并且只有当它上面的两个数字也是1.所以,


0000 0111

& 1100 0011

---------

0000 0011


它实际上比添加更简单和减法我们学会了

作为孩子!


如果您想获得有关如何将数字转换为二进制数(基数2)的帮助

系统,你可以私下给我发电子邮件。


- 智慧



I''m not sure about 1. Number 2 means, "Perform a `logical and'' operation
using x and 7 as operands."

This `logical and'' operation is done on numbers in the base 2 number system
(binary number system). Seven is 0000 0111 in this binary (base 2) number
system. Now, let''s say I take 1100 0011 and perform this `&'' operation
on these two numbers. ---------
It''s really simple. All you do is put a 1 underneath the dotted line when,
and only when, the two numbers above it are also 1. So,

0000 0111
& 1100 0011
---------
0000 0011

It''s actually simpler than the addition and subtraction we learned
as children!

If you would like help on how to convert numbers to the binary (base 2) number
system, you may email me privately.

--Steve


Steve Zimmerman写道:< br>
Steve Zimmerman wrote:
Bob Kensworth写道:
Bob Kensworth wrote:
你好。

这两个陈述是什么意思?

1)

#define stuff(x)(x>> 3)

2)

#define stuff1(x) (x& 7)

提前致谢,
Bob

我不确定1.数字2表示执行逻辑和''操作
使用x和7作为操作数。 ^^^^^^^^^^^
Hello.

What do these two statements mean?

1)

#define stuff(x) (x >> 3)

2)

#define stuff1(x) (x & 7)
Thanks in advance,
Bob
I''m not sure about 1. Number 2 means, "Perform a `logical and'' operation
using x and 7 as operands." ^^^^^^^^^^^




对不起。它不被称为逻辑和操作;它被称为

`按位和''操作。


--Steve -------------- ----

|


|这个`逻辑和''[我的意思是,'按位和'']操作是在基数为2的数字系统(二进制数系统)中的数字上完成的。七是这个二进制(基数2)数字系统中的0000 0111。现在,让我们说我接受1100 0011并对这两个数字执行这个'&''
操作。 ---------

这很简单。你所做的只是在虚线下面放一个1,当它,只有当它上面的两个数字也是1.所以,

0000 0111
& 1100 0011
----00-
0000 0011
它实际上比我们学习的加法和减法更简单! br />
如果您想获得有关如何将数字转换为二进制(基数2)数字
系统的帮助,您可以私下给我发电子邮件。

- -Steve



I''m sorry. It''s not called a `logical and'' operation; it''s called a
`bitwise and'' operation.

--Steve------------------
|

| |
This `logical and'' [I mean, `bitwise and''] operation is done on numbers in the base 2 number system
(binary number system). Seven is 0000 0111 in this binary (base 2) number
system. Now, let''s say I take 1100 0011 and perform this `&''
operation
on these two numbers. ---------
It''s really simple. All you do is put a 1 underneath the dotted line when,
and only when, the two numbers above it are also 1. So,

0000 0111
& 1100 0011
---------
0000 0011

It''s actually simpler than the addition and subtraction we learned
as children!

If you would like help on how to convert numbers to the binary (base 2)
number
system, you may email me privately.

--Steve



这篇关于声明问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆