Help
-
hello, can anyone helps me to know what does this function do I got confused in different operators. I will be grateul for you
void H(u64 diff, u64 &m, u64 &w) {
u64 m1 = 0;
u64 m8 = 0;
w = 0;
int i;for (i = 0; i < BLOCK\_SIZE; ++i) { if ((diff >> i) & 1) { // saw a 1 on position i // put zeroes on positions i+1 and i+8 m1 |= (0x1 << ((i+1)%BLOCK\_SIZE)); m8 |= (0x1 << ((i+8)%BLOCK\_SIZE)); } } m = (m1 | m8) ^ WORD\_MASK; for (i = 0; i < BLOCK\_SIZE; ++i) { if ( ((m1 >> i) & 1) == 0 && ((m8 >> i) & 1) == 1 && ((m1 >> ((i+7) % BLOCK\_SIZE)) & 1) == 1 && ((m8 >> ((i+7) % BLOCK\_SIZE)) & 1) == 0 ) w ^= (0x1ull << ((i+7) % BLOCK\_SIZE)); } m |= w;
}
-
hello, can anyone helps me to know what does this function do I got confused in different operators. I will be grateul for you
void H(u64 diff, u64 &m, u64 &w) {
u64 m1 = 0;
u64 m8 = 0;
w = 0;
int i;for (i = 0; i < BLOCK\_SIZE; ++i) { if ((diff >> i) & 1) { // saw a 1 on position i // put zeroes on positions i+1 and i+8 m1 |= (0x1 << ((i+1)%BLOCK\_SIZE)); m8 |= (0x1 << ((i+8)%BLOCK\_SIZE)); } } m = (m1 | m8) ^ WORD\_MASK; for (i = 0; i < BLOCK\_SIZE; ++i) { if ( ((m1 >> i) & 1) == 0 && ((m8 >> i) & 1) == 1 && ((m1 >> ((i+7) % BLOCK\_SIZE)) & 1) == 1 && ((m8 >> ((i+7) % BLOCK\_SIZE)) & 1) == 0 ) w ^= (0x1ull << ((i+7) % BLOCK\_SIZE)); } m |= w;
}
Operators in c++ is a pretty broad topic, are you having difficulty with one in particular? If not, maybe take a look at one or more of these. Operators in C++[^] Operators - C++ Tutorials[^] Operators in C++[^]
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
-
Operators in c++ is a pretty broad topic, are you having difficulty with one in particular? If not, maybe take a look at one or more of these. Operators in C++[^] Operators - C++ Tutorials[^] Operators in C++[^]
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
thanks Sir, but my problem is what this function do exactly I have an idea about operators
-
hello, can anyone helps me to know what does this function do I got confused in different operators. I will be grateul for you
void H(u64 diff, u64 &m, u64 &w) {
u64 m1 = 0;
u64 m8 = 0;
w = 0;
int i;for (i = 0; i < BLOCK\_SIZE; ++i) { if ((diff >> i) & 1) { // saw a 1 on position i // put zeroes on positions i+1 and i+8 m1 |= (0x1 << ((i+1)%BLOCK\_SIZE)); m8 |= (0x1 << ((i+8)%BLOCK\_SIZE)); } } m = (m1 | m8) ^ WORD\_MASK; for (i = 0; i < BLOCK\_SIZE; ++i) { if ( ((m1 >> i) & 1) == 0 && ((m8 >> i) & 1) == 1 && ((m1 >> ((i+7) % BLOCK\_SIZE)) & 1) == 1 && ((m8 >> ((i+7) % BLOCK\_SIZE)) & 1) == 0 ) w ^= (0x1ull << ((i+7) % BLOCK\_SIZE)); } m |= w;
}
-
hello, can anyone helps me to know what does this function do I got confused in different operators. I will be grateul for you
void H(u64 diff, u64 &m, u64 &w) {
u64 m1 = 0;
u64 m8 = 0;
w = 0;
int i;for (i = 0; i < BLOCK\_SIZE; ++i) { if ((diff >> i) & 1) { // saw a 1 on position i // put zeroes on positions i+1 and i+8 m1 |= (0x1 << ((i+1)%BLOCK\_SIZE)); m8 |= (0x1 << ((i+8)%BLOCK\_SIZE)); } } m = (m1 | m8) ^ WORD\_MASK; for (i = 0; i < BLOCK\_SIZE; ++i) { if ( ((m1 >> i) & 1) == 0 && ((m8 >> i) & 1) == 1 && ((m1 >> ((i+7) % BLOCK\_SIZE)) & 1) == 1 && ((m8 >> ((i+7) % BLOCK\_SIZE)) & 1) == 0 ) w ^= (0x1ull << ((i+7) % BLOCK\_SIZE)); } m |= w;
}
Member 13023118 wrote:
...what does this function do...
Where did you get it from?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
thanks Sir, but my problem is what this function do exactly I have an idea about operators
Looks like a CRC calculation on the data block. Look at code you haven't shown us and see what becomes of m & w. You actually haven't given us enough surrounding code to be able to conclusively work it out.
In vino veritas