Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help

Help

Scheduled Pinned Locked Moved C / C++ / MFC
help
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 13023118
    wrote on last edited by
    #1

    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;
    

    }

    J L D 3 Replies Last reply
    0
    • M Member 13023118

      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;
      

      }

      J Online
      J Online
      jeron1
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • J jeron1

        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

        M Offline
        M Offline
        Member 13023118
        wrote on last edited by
        #3

        thanks Sir, but my problem is what this function do exactly I have an idea about operators

        L 1 Reply Last reply
        0
        • M Member 13023118

          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;
          

          }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          It looks like it is some sort of encryption. You should ask the person you got it from.

          1 Reply Last reply
          0
          • M Member 13023118

            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;
            

            }

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • M Member 13023118

              thanks Sir, but my problem is what this function do exactly I have an idea about operators

              L Offline
              L Offline
              leon de boer
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups