k******r 发帖数: 2300 | 1 For example, if we want to use bit operations to swap two variables without
using temporary variable. Any one can tell me how to develop an approach to
using bit operations to solve such problems step by step. Because the bit
operations usually don't look intuitive so the thread of thoughts behind that
is very important in mastering bit operations. Thanks so much for your
tutorial. |
r******p 发帖数: 9 | 2 a ^= b;
b ^= a;
a ^= b;
that
【在 k******r 的大作中提到】 : For example, if we want to use bit operations to swap two variables without : using temporary variable. Any one can tell me how to develop an approach to : using bit operations to solve such problems step by step. Because the bit : operations usually don't look intuitive so the thread of thoughts behind that : is very important in mastering bit operations. Thanks so much for your : tutorial.
|
k******r 发帖数: 2300 | 3 Can you tell me how you get it? I guess it is more important than the answer.
【在 r******p 的大作中提到】 : a ^= b; : b ^= a; : a ^= b; : : that
|
r******p 发帖数: 9 | 4 (a^b)^b = a, with reflexivity
.
【在 k******r 的大作中提到】 : Can you tell me how you get it? I guess it is more important than the answer.
|
l***t 发帖数: 81 | 5 Actually, it is associativity for ^:
(a^b)^b = a^(b^b) = a^0 = a
【在 r******p 的大作中提到】 : (a^b)^b = a, with reflexivity : : .
|
r******p 发帖数: 9 | 6 以前有人贴过一个特全面介绍的link,找不到了
【在 l***t 的大作中提到】 : Actually, it is associativity for ^: : (a^b)^b = a^(b^b) = a^0 = a
|