嗯,它做了什么? [英] hmm, what does it do?
问题描述
#define BLACKBOX(x)((x)&((x)-1))
On Mon ,2005年2月21日12:54:26 -0800,puzzlecracker写道:
#define BLACKBOX(x)((x)&((x)-1))
一些实证分析:
1 - > 0
2 - > 0
3 - > 2
4 - > 0
5 - > 4
6 - > 4
7 - > 6
8 - > 0
9 - > 8
10 - > 8
11 - > 10
12 - > 8
13 - > 12
14 - > 12
15 - > 14
16 - > 0
看起来它可能是对2的力量的测试。 (结果为0或非零)。
- Jay
puzzlecracker写道:#define BLACKBOX(x)((x)&((x)-1))
它做什么......?不是C ++ ...我想说不推荐。
无论如何,你是拼图破解者! :-)告诉我们......
Andrea
puzzlecracker写道:#define BLACKBOX (x)((x)&((x)-1))
如果您认为输出为
布尔值(即只关注零与非零结果)。
-
后来,
杰瑞。
宇宙是一种自己的想象力。
#define BLACKBOX(x) ((x)&((x)-1))
On Mon, 21 Feb 2005 12:54:26 -0800, puzzlecracker wrote:
#define BLACKBOX(x) ((x)&((x)-1))
Some empirical analysis:
1 -> 0
2 -> 0
3 -> 2
4 -> 0
5 -> 4
6 -> 4
7 -> 6
8 -> 0
9 -> 8
10 -> 8
11 -> 10
12 -> 8
13 -> 12
14 -> 12
15 -> 14
16 -> 0
Looks like it could be a test for "power of 2" (result is 0 or non-zero).
- Jay
puzzlecracker wrote:#define BLACKBOX(x) ((x)&((x)-1))
What does it do...? Not C++...Deprecated, I would say.
Anyway, you are the puzzle cracker !!! :-) Tell us...
Andrea
puzzlecracker wrote:#define BLACKBOX(x) ((x)&((x)-1))
Perhaps it would help to get started if you thought of the output as a
boolean (i.e. paid attention only to zero vs. non-zero results).
--
Later,
Jerry.
The universe is a figment of its own imagination.
这篇关于嗯,它做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!