What is a^b and (a&b)<<1?2019 Community Moderator ElectionWhat is the most efficient way to deep clone an object in JavaScript?What is the preferred syntax for defining enums in JavaScript?What is the scope of variables in JavaScript?What is the !! (not not) operator in JavaScript?What is the JavaScript version of sleep()?What does “use strict” do in JavaScript, and what is the reasoning behind it?What is the 'new' keyword in JavaScript?What is the difference between call and apply?What is JSONP, and why was it created?What is the difference between Bower and npm?

Why Choose Less Effective Armour Types?

Sailing the cryptic seas

Existence of subset with given Hausdorff dimension

Recruiter wants very extensive technical details about all of my previous work

Define, (actually define) the "stability" and "energy" of a compound

Are all passive ability checks floors for active ability checks?

how to write formula in word in latex

Identifying the interval from A♭ to D♯

Why doesn't the EU now just force the UK to choose between referendum and no-deal?

In a future war, an old lady is trying to raise a boy but one of the weapons has made everyone deaf

Hacking a Safe Lock after 3 tries

What is the significance behind "40 days" that often appears in the Bible?

How to change two letters closest to a string and one letter immediately after a string using notepad++

If the DM rolls initiative once for a group of monsters, how do end-of-turn effects work?

Awsome yet unlucky path traversal

What exactly is this small puffer fish doing and how did it manage to accomplish such a feat?

Why did it take so long to abandon sail after steamships were demonstrated?

How do anti-virus programs start at Windows boot?

How to write cleanly even if my character uses expletive language?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

Min function accepting varying number of arguments in C++17

Could the Saturn V actually have launched astronauts around Venus?

If I can solve Sudoku can I solve Travelling Salesman Problem(TSP)? If yes, how?

If curse and magic is two sides of the same coin, why the former is forbidden?



What is a^b and (a&b)



2019 Community Moderator ElectionWhat is the most efficient way to deep clone an object in JavaScript?What is the preferred syntax for defining enums in JavaScript?What is the scope of variables in JavaScript?What is the !! (not not) operator in JavaScript?What is the JavaScript version of sleep()?What does “use strict” do in JavaScript, and what is the reasoning behind it?What is the 'new' keyword in JavaScript?What is the difference between call and apply?What is JSONP, and why was it created?What is the difference between Bower and npm?










8















I was doing this question in leetcode.



Request:




Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.




I can't understand the solution it gave



Could someone explain how this getSum function works?



Here is answer's JS:




var getSum=function(a,b)
const Sum=a^b;//I can't understand it.Please give me an example to understand it
const carry=(a&b)<<1;//I can't understand it too
if(!carry)
return Sum

return getSum(Sum,carry);
;
console.log(getSum(5,1));












share|improve this question


























    8















    I was doing this question in leetcode.



    Request:




    Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.




    I can't understand the solution it gave



    Could someone explain how this getSum function works?



    Here is answer's JS:




    var getSum=function(a,b)
    const Sum=a^b;//I can't understand it.Please give me an example to understand it
    const carry=(a&b)<<1;//I can't understand it too
    if(!carry)
    return Sum

    return getSum(Sum,carry);
    ;
    console.log(getSum(5,1));












    share|improve this question
























      8












      8








      8


      1






      I was doing this question in leetcode.



      Request:




      Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.




      I can't understand the solution it gave



      Could someone explain how this getSum function works?



      Here is answer's JS:




      var getSum=function(a,b)
      const Sum=a^b;//I can't understand it.Please give me an example to understand it
      const carry=(a&b)<<1;//I can't understand it too
      if(!carry)
      return Sum

      return getSum(Sum,carry);
      ;
      console.log(getSum(5,1));












      share|improve this question














      I was doing this question in leetcode.



      Request:




      Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.




      I can't understand the solution it gave



      Could someone explain how this getSum function works?



      Here is answer's JS:




      var getSum=function(a,b)
      const Sum=a^b;//I can't understand it.Please give me an example to understand it
      const carry=(a&b)<<1;//I can't understand it too
      if(!carry)
      return Sum

      return getSum(Sum,carry);
      ;
      console.log(getSum(5,1));








      var getSum=function(a,b)
      const Sum=a^b;//I can't understand it.Please give me an example to understand it
      const carry=(a&b)<<1;//I can't understand it too
      if(!carry)
      return Sum

      return getSum(Sum,carry);
      ;
      console.log(getSum(5,1));





      var getSum=function(a,b)
      const Sum=a^b;//I can't understand it.Please give me an example to understand it
      const carry=(a&b)<<1;//I can't understand it too
      if(!carry)
      return Sum

      return getSum(Sum,carry);
      ;
      console.log(getSum(5,1));






      javascript






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      JackyJacky

      1758




      1758






















          3 Answers
          3






          active

          oldest

          votes


















          9














          Let's imagine that a = 3 and b = 5



          In binary notation they are a = 0011 and b = 0101



          XOR:
          a^b is XOR operator. When compare two bits it returns 0 if they are same and 1 if they are different. 01^10 => 11



          So when we're doing a^b result will be 0110 (6 in decimal)



          AND + SHIFT



          a&b performs logical AND operation. It returns 1 only when a = b = 1.



          In our case the result is 0001



          << shifts it(adds 0 on the right side) and result became 0010 which sets carry variable true. (only 0000 will be false).



          Next iterations:



          Everything repeats but now a = 0110 and b = 0010 (Sum and carry from last execution)



          Now a^b = 0100 and (a&b)<<1 = 0100



          Repeating again.



          Now a^b = 0000 and (a&b)<<1 = 1000



          And again.



          Now a^b = 1000 and (a&b)<<1 = 0000. Now carry is finally false. And we're returning 1000 which is decimal 8.



          Everything worked fine since 3+5=8






          share|improve this answer




















          • 1





            Great explanation! I always find the bitwise operations hard to understand

            – Francisco Hanna
            32 mins ago


















          1














           int result = p ^ q; // XOR Operator, + without carry 0+0=0, 0+1=1+0=1, 1+1=0
          int carry = (p & q) << 1; // Left Shift, 1+1=2
          if (carry != 0)
          return getSum(result, carry);

          return result;


          Start By p=5,q=6. Then the XOR would be,



          0101
          0110
          ------
          0011


          So, XORing results in (0011) which is actually 3 in decimal. Then ANDing p and q we get,



          0101
          0110
          -------
          0100


          We get 4 (100 in binary) by ANDing 5 & 6, now if we left shift this value by 1, we get



           0100<<1=1000


          So we get 8 (1000 in binary) after first recursion.As the result (carry variable) isnt zero, lets recursion again by xor value and carry value.



          getSum(3, 8);


          So, doing the first XORing we get,



          0011
          1000
          -------
          1011


          The XORing this time yielded in 11 (1011 binary),so we perform the AND now,



          0011
          1000
          -------
          0000


          We get all ZERO for ANDing 3 and 8, so this time the left shift operator also results in ZERO, as we have no 1 here which may give us a value by left shifing zeroes.
          As the carry variable is now Zero, we come to the end of recursion and the XORed value will be the Sum, which is 11 (1011 in Binary).



          Hope you get the working of the procedure. You can learn more by learning bitwise operation, as its the way the machine do the arithmatic operations.






          share|improve this answer
































            -1














            These are bitwise operations. They're close to hardware language.






            share|improve this answer


















            • 7





              Too short.You didn't explain why this works and how

              – Jacky
              1 hour ago






            • 1





              Link-only answers are discouraged here. Please add the relevant content in the answer itself.

              – Ian McLaird
              1 hour ago






            • 3





              It’s binary math. WofWca would have to give you a very very long explanation on binary to explain it. You should really read the W3 Schools article or watch some videos on Bitwise calculations. It’s the kind of thing that would be a few days of class work in college. The comment about link-only answers is fair, but I doubt you’ll grasp the concept from a StackOverflow post alone though.

              – Nate
              1 hour ago












            • @Nate Sorry,But I am not the computer science's student

              – Jacky
              57 mins ago











            • @IanMcLaird It's not a link-only answer. The link content ("bitwise operations") is sufficient as an answer. Similar to an answer such as "Use the method abc.def.xyz".

              – user202729
              3 mins ago










            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55193135%2fwhat-is-ab-and-ab1%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            9














            Let's imagine that a = 3 and b = 5



            In binary notation they are a = 0011 and b = 0101



            XOR:
            a^b is XOR operator. When compare two bits it returns 0 if they are same and 1 if they are different. 01^10 => 11



            So when we're doing a^b result will be 0110 (6 in decimal)



            AND + SHIFT



            a&b performs logical AND operation. It returns 1 only when a = b = 1.



            In our case the result is 0001



            << shifts it(adds 0 on the right side) and result became 0010 which sets carry variable true. (only 0000 will be false).



            Next iterations:



            Everything repeats but now a = 0110 and b = 0010 (Sum and carry from last execution)



            Now a^b = 0100 and (a&b)<<1 = 0100



            Repeating again.



            Now a^b = 0000 and (a&b)<<1 = 1000



            And again.



            Now a^b = 1000 and (a&b)<<1 = 0000. Now carry is finally false. And we're returning 1000 which is decimal 8.



            Everything worked fine since 3+5=8






            share|improve this answer




















            • 1





              Great explanation! I always find the bitwise operations hard to understand

              – Francisco Hanna
              32 mins ago















            9














            Let's imagine that a = 3 and b = 5



            In binary notation they are a = 0011 and b = 0101



            XOR:
            a^b is XOR operator. When compare two bits it returns 0 if they are same and 1 if they are different. 01^10 => 11



            So when we're doing a^b result will be 0110 (6 in decimal)



            AND + SHIFT



            a&b performs logical AND operation. It returns 1 only when a = b = 1.



            In our case the result is 0001



            << shifts it(adds 0 on the right side) and result became 0010 which sets carry variable true. (only 0000 will be false).



            Next iterations:



            Everything repeats but now a = 0110 and b = 0010 (Sum and carry from last execution)



            Now a^b = 0100 and (a&b)<<1 = 0100



            Repeating again.



            Now a^b = 0000 and (a&b)<<1 = 1000



            And again.



            Now a^b = 1000 and (a&b)<<1 = 0000. Now carry is finally false. And we're returning 1000 which is decimal 8.



            Everything worked fine since 3+5=8






            share|improve this answer




















            • 1





              Great explanation! I always find the bitwise operations hard to understand

              – Francisco Hanna
              32 mins ago













            9












            9








            9







            Let's imagine that a = 3 and b = 5



            In binary notation they are a = 0011 and b = 0101



            XOR:
            a^b is XOR operator. When compare two bits it returns 0 if they are same and 1 if they are different. 01^10 => 11



            So when we're doing a^b result will be 0110 (6 in decimal)



            AND + SHIFT



            a&b performs logical AND operation. It returns 1 only when a = b = 1.



            In our case the result is 0001



            << shifts it(adds 0 on the right side) and result became 0010 which sets carry variable true. (only 0000 will be false).



            Next iterations:



            Everything repeats but now a = 0110 and b = 0010 (Sum and carry from last execution)



            Now a^b = 0100 and (a&b)<<1 = 0100



            Repeating again.



            Now a^b = 0000 and (a&b)<<1 = 1000



            And again.



            Now a^b = 1000 and (a&b)<<1 = 0000. Now carry is finally false. And we're returning 1000 which is decimal 8.



            Everything worked fine since 3+5=8






            share|improve this answer















            Let's imagine that a = 3 and b = 5



            In binary notation they are a = 0011 and b = 0101



            XOR:
            a^b is XOR operator. When compare two bits it returns 0 if they are same and 1 if they are different. 01^10 => 11



            So when we're doing a^b result will be 0110 (6 in decimal)



            AND + SHIFT



            a&b performs logical AND operation. It returns 1 only when a = b = 1.



            In our case the result is 0001



            << shifts it(adds 0 on the right side) and result became 0010 which sets carry variable true. (only 0000 will be false).



            Next iterations:



            Everything repeats but now a = 0110 and b = 0010 (Sum and carry from last execution)



            Now a^b = 0100 and (a&b)<<1 = 0100



            Repeating again.



            Now a^b = 0000 and (a&b)<<1 = 1000



            And again.



            Now a^b = 1000 and (a&b)<<1 = 0000. Now carry is finally false. And we're returning 1000 which is decimal 8.



            Everything worked fine since 3+5=8







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 38 mins ago

























            answered 55 mins ago









            vicodinvicodin

            1,097624




            1,097624







            • 1





              Great explanation! I always find the bitwise operations hard to understand

              – Francisco Hanna
              32 mins ago












            • 1





              Great explanation! I always find the bitwise operations hard to understand

              – Francisco Hanna
              32 mins ago







            1




            1





            Great explanation! I always find the bitwise operations hard to understand

            – Francisco Hanna
            32 mins ago





            Great explanation! I always find the bitwise operations hard to understand

            – Francisco Hanna
            32 mins ago













            1














             int result = p ^ q; // XOR Operator, + without carry 0+0=0, 0+1=1+0=1, 1+1=0
            int carry = (p & q) << 1; // Left Shift, 1+1=2
            if (carry != 0)
            return getSum(result, carry);

            return result;


            Start By p=5,q=6. Then the XOR would be,



            0101
            0110
            ------
            0011


            So, XORing results in (0011) which is actually 3 in decimal. Then ANDing p and q we get,



            0101
            0110
            -------
            0100


            We get 4 (100 in binary) by ANDing 5 & 6, now if we left shift this value by 1, we get



             0100<<1=1000


            So we get 8 (1000 in binary) after first recursion.As the result (carry variable) isnt zero, lets recursion again by xor value and carry value.



            getSum(3, 8);


            So, doing the first XORing we get,



            0011
            1000
            -------
            1011


            The XORing this time yielded in 11 (1011 binary),so we perform the AND now,



            0011
            1000
            -------
            0000


            We get all ZERO for ANDing 3 and 8, so this time the left shift operator also results in ZERO, as we have no 1 here which may give us a value by left shifing zeroes.
            As the carry variable is now Zero, we come to the end of recursion and the XORed value will be the Sum, which is 11 (1011 in Binary).



            Hope you get the working of the procedure. You can learn more by learning bitwise operation, as its the way the machine do the arithmatic operations.






            share|improve this answer





























              1














               int result = p ^ q; // XOR Operator, + without carry 0+0=0, 0+1=1+0=1, 1+1=0
              int carry = (p & q) << 1; // Left Shift, 1+1=2
              if (carry != 0)
              return getSum(result, carry);

              return result;


              Start By p=5,q=6. Then the XOR would be,



              0101
              0110
              ------
              0011


              So, XORing results in (0011) which is actually 3 in decimal. Then ANDing p and q we get,



              0101
              0110
              -------
              0100


              We get 4 (100 in binary) by ANDing 5 & 6, now if we left shift this value by 1, we get



               0100<<1=1000


              So we get 8 (1000 in binary) after first recursion.As the result (carry variable) isnt zero, lets recursion again by xor value and carry value.



              getSum(3, 8);


              So, doing the first XORing we get,



              0011
              1000
              -------
              1011


              The XORing this time yielded in 11 (1011 binary),so we perform the AND now,



              0011
              1000
              -------
              0000


              We get all ZERO for ANDing 3 and 8, so this time the left shift operator also results in ZERO, as we have no 1 here which may give us a value by left shifing zeroes.
              As the carry variable is now Zero, we come to the end of recursion and the XORed value will be the Sum, which is 11 (1011 in Binary).



              Hope you get the working of the procedure. You can learn more by learning bitwise operation, as its the way the machine do the arithmatic operations.






              share|improve this answer



























                1












                1








                1







                 int result = p ^ q; // XOR Operator, + without carry 0+0=0, 0+1=1+0=1, 1+1=0
                int carry = (p & q) << 1; // Left Shift, 1+1=2
                if (carry != 0)
                return getSum(result, carry);

                return result;


                Start By p=5,q=6. Then the XOR would be,



                0101
                0110
                ------
                0011


                So, XORing results in (0011) which is actually 3 in decimal. Then ANDing p and q we get,



                0101
                0110
                -------
                0100


                We get 4 (100 in binary) by ANDing 5 & 6, now if we left shift this value by 1, we get



                 0100<<1=1000


                So we get 8 (1000 in binary) after first recursion.As the result (carry variable) isnt zero, lets recursion again by xor value and carry value.



                getSum(3, 8);


                So, doing the first XORing we get,



                0011
                1000
                -------
                1011


                The XORing this time yielded in 11 (1011 binary),so we perform the AND now,



                0011
                1000
                -------
                0000


                We get all ZERO for ANDing 3 and 8, so this time the left shift operator also results in ZERO, as we have no 1 here which may give us a value by left shifing zeroes.
                As the carry variable is now Zero, we come to the end of recursion and the XORed value will be the Sum, which is 11 (1011 in Binary).



                Hope you get the working of the procedure. You can learn more by learning bitwise operation, as its the way the machine do the arithmatic operations.






                share|improve this answer















                 int result = p ^ q; // XOR Operator, + without carry 0+0=0, 0+1=1+0=1, 1+1=0
                int carry = (p & q) << 1; // Left Shift, 1+1=2
                if (carry != 0)
                return getSum(result, carry);

                return result;


                Start By p=5,q=6. Then the XOR would be,



                0101
                0110
                ------
                0011


                So, XORing results in (0011) which is actually 3 in decimal. Then ANDing p and q we get,



                0101
                0110
                -------
                0100


                We get 4 (100 in binary) by ANDing 5 & 6, now if we left shift this value by 1, we get



                 0100<<1=1000


                So we get 8 (1000 in binary) after first recursion.As the result (carry variable) isnt zero, lets recursion again by xor value and carry value.



                getSum(3, 8);


                So, doing the first XORing we get,



                0011
                1000
                -------
                1011


                The XORing this time yielded in 11 (1011 binary),so we perform the AND now,



                0011
                1000
                -------
                0000


                We get all ZERO for ANDing 3 and 8, so this time the left shift operator also results in ZERO, as we have no 1 here which may give us a value by left shifing zeroes.
                As the carry variable is now Zero, we come to the end of recursion and the XORed value will be the Sum, which is 11 (1011 in Binary).



                Hope you get the working of the procedure. You can learn more by learning bitwise operation, as its the way the machine do the arithmatic operations.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 41 mins ago

























                answered 46 mins ago









                Ayan_84Ayan_84

                520513




                520513





















                    -1














                    These are bitwise operations. They're close to hardware language.






                    share|improve this answer


















                    • 7





                      Too short.You didn't explain why this works and how

                      – Jacky
                      1 hour ago






                    • 1





                      Link-only answers are discouraged here. Please add the relevant content in the answer itself.

                      – Ian McLaird
                      1 hour ago






                    • 3





                      It’s binary math. WofWca would have to give you a very very long explanation on binary to explain it. You should really read the W3 Schools article or watch some videos on Bitwise calculations. It’s the kind of thing that would be a few days of class work in college. The comment about link-only answers is fair, but I doubt you’ll grasp the concept from a StackOverflow post alone though.

                      – Nate
                      1 hour ago












                    • @Nate Sorry,But I am not the computer science's student

                      – Jacky
                      57 mins ago











                    • @IanMcLaird It's not a link-only answer. The link content ("bitwise operations") is sufficient as an answer. Similar to an answer such as "Use the method abc.def.xyz".

                      – user202729
                      3 mins ago















                    -1














                    These are bitwise operations. They're close to hardware language.






                    share|improve this answer


















                    • 7





                      Too short.You didn't explain why this works and how

                      – Jacky
                      1 hour ago






                    • 1





                      Link-only answers are discouraged here. Please add the relevant content in the answer itself.

                      – Ian McLaird
                      1 hour ago






                    • 3





                      It’s binary math. WofWca would have to give you a very very long explanation on binary to explain it. You should really read the W3 Schools article or watch some videos on Bitwise calculations. It’s the kind of thing that would be a few days of class work in college. The comment about link-only answers is fair, but I doubt you’ll grasp the concept from a StackOverflow post alone though.

                      – Nate
                      1 hour ago












                    • @Nate Sorry,But I am not the computer science's student

                      – Jacky
                      57 mins ago











                    • @IanMcLaird It's not a link-only answer. The link content ("bitwise operations") is sufficient as an answer. Similar to an answer such as "Use the method abc.def.xyz".

                      – user202729
                      3 mins ago













                    -1












                    -1








                    -1







                    These are bitwise operations. They're close to hardware language.






                    share|improve this answer













                    These are bitwise operations. They're close to hardware language.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 1 hour ago









                    WofWcaWofWca

                    40819




                    40819







                    • 7





                      Too short.You didn't explain why this works and how

                      – Jacky
                      1 hour ago






                    • 1





                      Link-only answers are discouraged here. Please add the relevant content in the answer itself.

                      – Ian McLaird
                      1 hour ago






                    • 3





                      It’s binary math. WofWca would have to give you a very very long explanation on binary to explain it. You should really read the W3 Schools article or watch some videos on Bitwise calculations. It’s the kind of thing that would be a few days of class work in college. The comment about link-only answers is fair, but I doubt you’ll grasp the concept from a StackOverflow post alone though.

                      – Nate
                      1 hour ago












                    • @Nate Sorry,But I am not the computer science's student

                      – Jacky
                      57 mins ago











                    • @IanMcLaird It's not a link-only answer. The link content ("bitwise operations") is sufficient as an answer. Similar to an answer such as "Use the method abc.def.xyz".

                      – user202729
                      3 mins ago












                    • 7





                      Too short.You didn't explain why this works and how

                      – Jacky
                      1 hour ago






                    • 1





                      Link-only answers are discouraged here. Please add the relevant content in the answer itself.

                      – Ian McLaird
                      1 hour ago






                    • 3





                      It’s binary math. WofWca would have to give you a very very long explanation on binary to explain it. You should really read the W3 Schools article or watch some videos on Bitwise calculations. It’s the kind of thing that would be a few days of class work in college. The comment about link-only answers is fair, but I doubt you’ll grasp the concept from a StackOverflow post alone though.

                      – Nate
                      1 hour ago












                    • @Nate Sorry,But I am not the computer science's student

                      – Jacky
                      57 mins ago











                    • @IanMcLaird It's not a link-only answer. The link content ("bitwise operations") is sufficient as an answer. Similar to an answer such as "Use the method abc.def.xyz".

                      – user202729
                      3 mins ago







                    7




                    7





                    Too short.You didn't explain why this works and how

                    – Jacky
                    1 hour ago





                    Too short.You didn't explain why this works and how

                    – Jacky
                    1 hour ago




                    1




                    1





                    Link-only answers are discouraged here. Please add the relevant content in the answer itself.

                    – Ian McLaird
                    1 hour ago





                    Link-only answers are discouraged here. Please add the relevant content in the answer itself.

                    – Ian McLaird
                    1 hour ago




                    3




                    3





                    It’s binary math. WofWca would have to give you a very very long explanation on binary to explain it. You should really read the W3 Schools article or watch some videos on Bitwise calculations. It’s the kind of thing that would be a few days of class work in college. The comment about link-only answers is fair, but I doubt you’ll grasp the concept from a StackOverflow post alone though.

                    – Nate
                    1 hour ago






                    It’s binary math. WofWca would have to give you a very very long explanation on binary to explain it. You should really read the W3 Schools article or watch some videos on Bitwise calculations. It’s the kind of thing that would be a few days of class work in college. The comment about link-only answers is fair, but I doubt you’ll grasp the concept from a StackOverflow post alone though.

                    – Nate
                    1 hour ago














                    @Nate Sorry,But I am not the computer science's student

                    – Jacky
                    57 mins ago





                    @Nate Sorry,But I am not the computer science's student

                    – Jacky
                    57 mins ago













                    @IanMcLaird It's not a link-only answer. The link content ("bitwise operations") is sufficient as an answer. Similar to an answer such as "Use the method abc.def.xyz".

                    – user202729
                    3 mins ago





                    @IanMcLaird It's not a link-only answer. The link content ("bitwise operations") is sufficient as an answer. Similar to an answer such as "Use the method abc.def.xyz".

                    – user202729
                    3 mins ago

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55193135%2fwhat-is-ab-and-ab1%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Isabella Eugénie Boyer Biographie | Références | Menu de navigationmodifiermodifier le codeComparator to Compute the Relative Value of a U.S. Dollar Amount – 1774 to Present.

                    Mpande kaSenzangakhona Biographie | Références | Menu de navigationmodifierMpande kaSenzangakhonavoir la liste des auteursm

                    Hornos de Moncalvillo Voir aussi | Menu de navigationmodifierm