Change Arithmetic Right Shift to Logical Right Shift












0












$begingroup$


The following code is a solution to a textbook (Bryant&O'Hallaron: Computer Systems A programmer's Perspective 2nd Ed) problem in bit-level data manipulation (attempted for the challenge, not a class). The function srl is not written necessarily in a practical manner, but within the constraints required by the problem.



Questions



Is there is a clearer, more straight-forward way to write this within the required constraints of the problem (perhaps with fewer ~ operations)?



There is a need to avoid undefined behavior of the left shift, when k = 0. In this case int_bits - k = int_bits, which causes the shift to work unpredictably. Is there a better way to handle the undefined behavior of the shift operations, when the shift is larger than the number of bits in the interger?



It seems to work correctly, but I lack an answer, so any feedback on the solution would be appreciated.



Requirements





  • No additional right shifts or type casts may be used beyond the given expression



      /*Perform shift arithmetically*/
    unsigned xsra = (int) x >> k;


  • Only addition or subtraction may be used, no multiplication, division, or modulus


  • No comparison operators and no conditionals


  • Only bit-wise operations (except further right shifts) and logical operators may be used



Code



unsigned srl(unsigned x, int k) {
/*Perform shift arithmetically*/
unsigned xsra = (int) x >> k;

unsigned int_bits = sizeof(int) << 3;//calculates the number of bits in int (assumes 8-bit byte)

unsigned zero_or_all_bits = ~0 + !k;//for k = 0, corrects for the undefined behavior in
//the left shift produced from int_bits - k = int_bits
//if k != 0, !k == 0, and zero_or_all_bits == ~0
//if k == 0, zero_or_all_bits == 0

unsigned high_bit_mask = ~(zero_or_all_bits << (zero_or_all_bits & (int_bits - k)));
/******************************************/
//creates a mask of either all bits set in an unsigned int (UINT_MAX)
//or a mask with k high bits cleared.
//if k == 0, then high_bit_mask = ~(0 << 0) = ~0.
//if k != 0, then high_bit_mask = ~(~0 << (~0 & (int_bits - k)))
//ex. k == 3, high_bit_mask == 0x1FFFFFFF
//ex. k == 0, high_bit_mask == 0xFFFFFFFF
//ex. k == 31, high_bit_mask == 0xFFFFFFFE
/******************************************/

return xsra & high_bit_mask;


}





Test Code



printf("Test srl:n");
printf("srl(-1, 1): 0x%.8xn", srl(-1, 1));
printf("srl(-1, 4): 0x%.8xn", srl(-1, 4));
printf("srl(-1, 5): 0x%.8xn", srl(-1, 5));
printf("srl(-1, 31): 0x%.8xn", srl(-1, 31));
printf("srl(-1, 0): 0x%.8xn", srl(-1, 0));

printf("srl(0x7FFFFFFF, 1): 0x%.8xn", srl(0x7FFFFFFF, 1));
printf("srl(0x7FFFFFFF, 4): 0x%.8xn", srl(0x7FFFFFFF, 4));
printf("srl(0x7FFFFFFF, 5): 0x%.8xn", srl(0x7FFFFFFF, 5));
printf("srl(0x7FFFFFFF, 31): 0x%.8xn", srl(0x7FFFFFFF, 31));
printf("srl(0x7FFFFFFF, 0): 0x%.8xn", srl(0x7FFFFFFF, 0));

printf("srl(0x80000000, 1): 0x%.8xn", srl(0x80000000, 1));
printf("srl(0x80000000, 4): 0x%.8xn", srl(0x80000000, 4));
printf("srl(0x80000000, 5): 0x%.8xn", srl(0x80000000, 5));
printf("srl(0x80000000, 31): 0x%.8xn", srl(0x80000000, 31));
printf("srl(0x80000000, 0): 0x%.8xn", srl(0x80000000, 0));

printf("srl(0, 1): 0x%.8xn", srl(0, 1));
printf("srl(0, 4): 0x%.8xn", srl(0, 4));
printf("srl(0, 5): 0x%.8xn", srl(0, 5));
printf("srl(0, 31): 0x%.8xn", srl(0, 31));
printf("srl(0, 0): 0x%.8xn", srl(0, 0));

printf("srl(1, 1): 0x%.8xn", srl(1, 1));
printf("srl(1, 4): 0x%.8xn", srl(1, 4));
printf("srl(1, 5): 0x%.8xn", srl(1, 5));
printf("srl(1, 31): 0x%.8xn", srl(1, 31));
printf("srl(1, 0): 0x%.8xn", srl(1, 0));




Output




Test srl:

srl(-1, 1): 0x7fffffff

srl(-1, 4): 0x0fffffff

srl(-1, 5): 0x07ffffff

srl(-1, 31): 0x00000001

srl(-1, 0): 0xffffffff

srl(0x7FFFFFFF, 1): 0x3fffffff

srl(0x7FFFFFFF, 4): 0x07ffffff

srl(0x7FFFFFFF, 5): 0x03ffffff

srl(0x7FFFFFFF, 31): 0x00000000

srl(0x7FFFFFFF, 0): 0x7fffffff

srl(0x80000000, 1): 0x40000000

srl(0x80000000, 4): 0x08000000

srl(0x80000000, 5): 0x04000000

srl(0x80000000, 31): 0x00000001

srl(0x80000000, 0): 0x80000000

srl(0, 1): 0x00000000

srl(0, 4): 0x00000000

srl(0, 5): 0x00000000

srl(0, 31): 0x00000000

srl(0, 0): 0x00000000

srl(1, 1): 0x00000000

srl(1, 4): 0x00000000

srl(1, 5): 0x00000000

srl(1, 31): 0x00000000

srl(1, 0): 0x00000001










share









$endgroup$

















    0












    $begingroup$


    The following code is a solution to a textbook (Bryant&O'Hallaron: Computer Systems A programmer's Perspective 2nd Ed) problem in bit-level data manipulation (attempted for the challenge, not a class). The function srl is not written necessarily in a practical manner, but within the constraints required by the problem.



    Questions



    Is there is a clearer, more straight-forward way to write this within the required constraints of the problem (perhaps with fewer ~ operations)?



    There is a need to avoid undefined behavior of the left shift, when k = 0. In this case int_bits - k = int_bits, which causes the shift to work unpredictably. Is there a better way to handle the undefined behavior of the shift operations, when the shift is larger than the number of bits in the interger?



    It seems to work correctly, but I lack an answer, so any feedback on the solution would be appreciated.



    Requirements





    • No additional right shifts or type casts may be used beyond the given expression



        /*Perform shift arithmetically*/
      unsigned xsra = (int) x >> k;


    • Only addition or subtraction may be used, no multiplication, division, or modulus


    • No comparison operators and no conditionals


    • Only bit-wise operations (except further right shifts) and logical operators may be used



    Code



    unsigned srl(unsigned x, int k) {
    /*Perform shift arithmetically*/
    unsigned xsra = (int) x >> k;

    unsigned int_bits = sizeof(int) << 3;//calculates the number of bits in int (assumes 8-bit byte)

    unsigned zero_or_all_bits = ~0 + !k;//for k = 0, corrects for the undefined behavior in
    //the left shift produced from int_bits - k = int_bits
    //if k != 0, !k == 0, and zero_or_all_bits == ~0
    //if k == 0, zero_or_all_bits == 0

    unsigned high_bit_mask = ~(zero_or_all_bits << (zero_or_all_bits & (int_bits - k)));
    /******************************************/
    //creates a mask of either all bits set in an unsigned int (UINT_MAX)
    //or a mask with k high bits cleared.
    //if k == 0, then high_bit_mask = ~(0 << 0) = ~0.
    //if k != 0, then high_bit_mask = ~(~0 << (~0 & (int_bits - k)))
    //ex. k == 3, high_bit_mask == 0x1FFFFFFF
    //ex. k == 0, high_bit_mask == 0xFFFFFFFF
    //ex. k == 31, high_bit_mask == 0xFFFFFFFE
    /******************************************/

    return xsra & high_bit_mask;


    }





    Test Code



    printf("Test srl:n");
    printf("srl(-1, 1): 0x%.8xn", srl(-1, 1));
    printf("srl(-1, 4): 0x%.8xn", srl(-1, 4));
    printf("srl(-1, 5): 0x%.8xn", srl(-1, 5));
    printf("srl(-1, 31): 0x%.8xn", srl(-1, 31));
    printf("srl(-1, 0): 0x%.8xn", srl(-1, 0));

    printf("srl(0x7FFFFFFF, 1): 0x%.8xn", srl(0x7FFFFFFF, 1));
    printf("srl(0x7FFFFFFF, 4): 0x%.8xn", srl(0x7FFFFFFF, 4));
    printf("srl(0x7FFFFFFF, 5): 0x%.8xn", srl(0x7FFFFFFF, 5));
    printf("srl(0x7FFFFFFF, 31): 0x%.8xn", srl(0x7FFFFFFF, 31));
    printf("srl(0x7FFFFFFF, 0): 0x%.8xn", srl(0x7FFFFFFF, 0));

    printf("srl(0x80000000, 1): 0x%.8xn", srl(0x80000000, 1));
    printf("srl(0x80000000, 4): 0x%.8xn", srl(0x80000000, 4));
    printf("srl(0x80000000, 5): 0x%.8xn", srl(0x80000000, 5));
    printf("srl(0x80000000, 31): 0x%.8xn", srl(0x80000000, 31));
    printf("srl(0x80000000, 0): 0x%.8xn", srl(0x80000000, 0));

    printf("srl(0, 1): 0x%.8xn", srl(0, 1));
    printf("srl(0, 4): 0x%.8xn", srl(0, 4));
    printf("srl(0, 5): 0x%.8xn", srl(0, 5));
    printf("srl(0, 31): 0x%.8xn", srl(0, 31));
    printf("srl(0, 0): 0x%.8xn", srl(0, 0));

    printf("srl(1, 1): 0x%.8xn", srl(1, 1));
    printf("srl(1, 4): 0x%.8xn", srl(1, 4));
    printf("srl(1, 5): 0x%.8xn", srl(1, 5));
    printf("srl(1, 31): 0x%.8xn", srl(1, 31));
    printf("srl(1, 0): 0x%.8xn", srl(1, 0));




    Output




    Test srl:

    srl(-1, 1): 0x7fffffff

    srl(-1, 4): 0x0fffffff

    srl(-1, 5): 0x07ffffff

    srl(-1, 31): 0x00000001

    srl(-1, 0): 0xffffffff

    srl(0x7FFFFFFF, 1): 0x3fffffff

    srl(0x7FFFFFFF, 4): 0x07ffffff

    srl(0x7FFFFFFF, 5): 0x03ffffff

    srl(0x7FFFFFFF, 31): 0x00000000

    srl(0x7FFFFFFF, 0): 0x7fffffff

    srl(0x80000000, 1): 0x40000000

    srl(0x80000000, 4): 0x08000000

    srl(0x80000000, 5): 0x04000000

    srl(0x80000000, 31): 0x00000001

    srl(0x80000000, 0): 0x80000000

    srl(0, 1): 0x00000000

    srl(0, 4): 0x00000000

    srl(0, 5): 0x00000000

    srl(0, 31): 0x00000000

    srl(0, 0): 0x00000000

    srl(1, 1): 0x00000000

    srl(1, 4): 0x00000000

    srl(1, 5): 0x00000000

    srl(1, 31): 0x00000000

    srl(1, 0): 0x00000001










    share









    $endgroup$















      0












      0








      0





      $begingroup$


      The following code is a solution to a textbook (Bryant&O'Hallaron: Computer Systems A programmer's Perspective 2nd Ed) problem in bit-level data manipulation (attempted for the challenge, not a class). The function srl is not written necessarily in a practical manner, but within the constraints required by the problem.



      Questions



      Is there is a clearer, more straight-forward way to write this within the required constraints of the problem (perhaps with fewer ~ operations)?



      There is a need to avoid undefined behavior of the left shift, when k = 0. In this case int_bits - k = int_bits, which causes the shift to work unpredictably. Is there a better way to handle the undefined behavior of the shift operations, when the shift is larger than the number of bits in the interger?



      It seems to work correctly, but I lack an answer, so any feedback on the solution would be appreciated.



      Requirements





      • No additional right shifts or type casts may be used beyond the given expression



          /*Perform shift arithmetically*/
        unsigned xsra = (int) x >> k;


      • Only addition or subtraction may be used, no multiplication, division, or modulus


      • No comparison operators and no conditionals


      • Only bit-wise operations (except further right shifts) and logical operators may be used



      Code



      unsigned srl(unsigned x, int k) {
      /*Perform shift arithmetically*/
      unsigned xsra = (int) x >> k;

      unsigned int_bits = sizeof(int) << 3;//calculates the number of bits in int (assumes 8-bit byte)

      unsigned zero_or_all_bits = ~0 + !k;//for k = 0, corrects for the undefined behavior in
      //the left shift produced from int_bits - k = int_bits
      //if k != 0, !k == 0, and zero_or_all_bits == ~0
      //if k == 0, zero_or_all_bits == 0

      unsigned high_bit_mask = ~(zero_or_all_bits << (zero_or_all_bits & (int_bits - k)));
      /******************************************/
      //creates a mask of either all bits set in an unsigned int (UINT_MAX)
      //or a mask with k high bits cleared.
      //if k == 0, then high_bit_mask = ~(0 << 0) = ~0.
      //if k != 0, then high_bit_mask = ~(~0 << (~0 & (int_bits - k)))
      //ex. k == 3, high_bit_mask == 0x1FFFFFFF
      //ex. k == 0, high_bit_mask == 0xFFFFFFFF
      //ex. k == 31, high_bit_mask == 0xFFFFFFFE
      /******************************************/

      return xsra & high_bit_mask;


      }





      Test Code



      printf("Test srl:n");
      printf("srl(-1, 1): 0x%.8xn", srl(-1, 1));
      printf("srl(-1, 4): 0x%.8xn", srl(-1, 4));
      printf("srl(-1, 5): 0x%.8xn", srl(-1, 5));
      printf("srl(-1, 31): 0x%.8xn", srl(-1, 31));
      printf("srl(-1, 0): 0x%.8xn", srl(-1, 0));

      printf("srl(0x7FFFFFFF, 1): 0x%.8xn", srl(0x7FFFFFFF, 1));
      printf("srl(0x7FFFFFFF, 4): 0x%.8xn", srl(0x7FFFFFFF, 4));
      printf("srl(0x7FFFFFFF, 5): 0x%.8xn", srl(0x7FFFFFFF, 5));
      printf("srl(0x7FFFFFFF, 31): 0x%.8xn", srl(0x7FFFFFFF, 31));
      printf("srl(0x7FFFFFFF, 0): 0x%.8xn", srl(0x7FFFFFFF, 0));

      printf("srl(0x80000000, 1): 0x%.8xn", srl(0x80000000, 1));
      printf("srl(0x80000000, 4): 0x%.8xn", srl(0x80000000, 4));
      printf("srl(0x80000000, 5): 0x%.8xn", srl(0x80000000, 5));
      printf("srl(0x80000000, 31): 0x%.8xn", srl(0x80000000, 31));
      printf("srl(0x80000000, 0): 0x%.8xn", srl(0x80000000, 0));

      printf("srl(0, 1): 0x%.8xn", srl(0, 1));
      printf("srl(0, 4): 0x%.8xn", srl(0, 4));
      printf("srl(0, 5): 0x%.8xn", srl(0, 5));
      printf("srl(0, 31): 0x%.8xn", srl(0, 31));
      printf("srl(0, 0): 0x%.8xn", srl(0, 0));

      printf("srl(1, 1): 0x%.8xn", srl(1, 1));
      printf("srl(1, 4): 0x%.8xn", srl(1, 4));
      printf("srl(1, 5): 0x%.8xn", srl(1, 5));
      printf("srl(1, 31): 0x%.8xn", srl(1, 31));
      printf("srl(1, 0): 0x%.8xn", srl(1, 0));




      Output




      Test srl:

      srl(-1, 1): 0x7fffffff

      srl(-1, 4): 0x0fffffff

      srl(-1, 5): 0x07ffffff

      srl(-1, 31): 0x00000001

      srl(-1, 0): 0xffffffff

      srl(0x7FFFFFFF, 1): 0x3fffffff

      srl(0x7FFFFFFF, 4): 0x07ffffff

      srl(0x7FFFFFFF, 5): 0x03ffffff

      srl(0x7FFFFFFF, 31): 0x00000000

      srl(0x7FFFFFFF, 0): 0x7fffffff

      srl(0x80000000, 1): 0x40000000

      srl(0x80000000, 4): 0x08000000

      srl(0x80000000, 5): 0x04000000

      srl(0x80000000, 31): 0x00000001

      srl(0x80000000, 0): 0x80000000

      srl(0, 1): 0x00000000

      srl(0, 4): 0x00000000

      srl(0, 5): 0x00000000

      srl(0, 31): 0x00000000

      srl(0, 0): 0x00000000

      srl(1, 1): 0x00000000

      srl(1, 4): 0x00000000

      srl(1, 5): 0x00000000

      srl(1, 31): 0x00000000

      srl(1, 0): 0x00000001










      share









      $endgroup$




      The following code is a solution to a textbook (Bryant&O'Hallaron: Computer Systems A programmer's Perspective 2nd Ed) problem in bit-level data manipulation (attempted for the challenge, not a class). The function srl is not written necessarily in a practical manner, but within the constraints required by the problem.



      Questions



      Is there is a clearer, more straight-forward way to write this within the required constraints of the problem (perhaps with fewer ~ operations)?



      There is a need to avoid undefined behavior of the left shift, when k = 0. In this case int_bits - k = int_bits, which causes the shift to work unpredictably. Is there a better way to handle the undefined behavior of the shift operations, when the shift is larger than the number of bits in the interger?



      It seems to work correctly, but I lack an answer, so any feedback on the solution would be appreciated.



      Requirements





      • No additional right shifts or type casts may be used beyond the given expression



          /*Perform shift arithmetically*/
        unsigned xsra = (int) x >> k;


      • Only addition or subtraction may be used, no multiplication, division, or modulus


      • No comparison operators and no conditionals


      • Only bit-wise operations (except further right shifts) and logical operators may be used



      Code



      unsigned srl(unsigned x, int k) {
      /*Perform shift arithmetically*/
      unsigned xsra = (int) x >> k;

      unsigned int_bits = sizeof(int) << 3;//calculates the number of bits in int (assumes 8-bit byte)

      unsigned zero_or_all_bits = ~0 + !k;//for k = 0, corrects for the undefined behavior in
      //the left shift produced from int_bits - k = int_bits
      //if k != 0, !k == 0, and zero_or_all_bits == ~0
      //if k == 0, zero_or_all_bits == 0

      unsigned high_bit_mask = ~(zero_or_all_bits << (zero_or_all_bits & (int_bits - k)));
      /******************************************/
      //creates a mask of either all bits set in an unsigned int (UINT_MAX)
      //or a mask with k high bits cleared.
      //if k == 0, then high_bit_mask = ~(0 << 0) = ~0.
      //if k != 0, then high_bit_mask = ~(~0 << (~0 & (int_bits - k)))
      //ex. k == 3, high_bit_mask == 0x1FFFFFFF
      //ex. k == 0, high_bit_mask == 0xFFFFFFFF
      //ex. k == 31, high_bit_mask == 0xFFFFFFFE
      /******************************************/

      return xsra & high_bit_mask;


      }





      Test Code



      printf("Test srl:n");
      printf("srl(-1, 1): 0x%.8xn", srl(-1, 1));
      printf("srl(-1, 4): 0x%.8xn", srl(-1, 4));
      printf("srl(-1, 5): 0x%.8xn", srl(-1, 5));
      printf("srl(-1, 31): 0x%.8xn", srl(-1, 31));
      printf("srl(-1, 0): 0x%.8xn", srl(-1, 0));

      printf("srl(0x7FFFFFFF, 1): 0x%.8xn", srl(0x7FFFFFFF, 1));
      printf("srl(0x7FFFFFFF, 4): 0x%.8xn", srl(0x7FFFFFFF, 4));
      printf("srl(0x7FFFFFFF, 5): 0x%.8xn", srl(0x7FFFFFFF, 5));
      printf("srl(0x7FFFFFFF, 31): 0x%.8xn", srl(0x7FFFFFFF, 31));
      printf("srl(0x7FFFFFFF, 0): 0x%.8xn", srl(0x7FFFFFFF, 0));

      printf("srl(0x80000000, 1): 0x%.8xn", srl(0x80000000, 1));
      printf("srl(0x80000000, 4): 0x%.8xn", srl(0x80000000, 4));
      printf("srl(0x80000000, 5): 0x%.8xn", srl(0x80000000, 5));
      printf("srl(0x80000000, 31): 0x%.8xn", srl(0x80000000, 31));
      printf("srl(0x80000000, 0): 0x%.8xn", srl(0x80000000, 0));

      printf("srl(0, 1): 0x%.8xn", srl(0, 1));
      printf("srl(0, 4): 0x%.8xn", srl(0, 4));
      printf("srl(0, 5): 0x%.8xn", srl(0, 5));
      printf("srl(0, 31): 0x%.8xn", srl(0, 31));
      printf("srl(0, 0): 0x%.8xn", srl(0, 0));

      printf("srl(1, 1): 0x%.8xn", srl(1, 1));
      printf("srl(1, 4): 0x%.8xn", srl(1, 4));
      printf("srl(1, 5): 0x%.8xn", srl(1, 5));
      printf("srl(1, 31): 0x%.8xn", srl(1, 31));
      printf("srl(1, 0): 0x%.8xn", srl(1, 0));




      Output




      Test srl:

      srl(-1, 1): 0x7fffffff

      srl(-1, 4): 0x0fffffff

      srl(-1, 5): 0x07ffffff

      srl(-1, 31): 0x00000001

      srl(-1, 0): 0xffffffff

      srl(0x7FFFFFFF, 1): 0x3fffffff

      srl(0x7FFFFFFF, 4): 0x07ffffff

      srl(0x7FFFFFFF, 5): 0x03ffffff

      srl(0x7FFFFFFF, 31): 0x00000000

      srl(0x7FFFFFFF, 0): 0x7fffffff

      srl(0x80000000, 1): 0x40000000

      srl(0x80000000, 4): 0x08000000

      srl(0x80000000, 5): 0x04000000

      srl(0x80000000, 31): 0x00000001

      srl(0x80000000, 0): 0x80000000

      srl(0, 1): 0x00000000

      srl(0, 4): 0x00000000

      srl(0, 5): 0x00000000

      srl(0, 31): 0x00000000

      srl(0, 0): 0x00000000

      srl(1, 1): 0x00000000

      srl(1, 4): 0x00000000

      srl(1, 5): 0x00000000

      srl(1, 31): 0x00000000

      srl(1, 0): 0x00000001








      c integer bitwise





      share












      share










      share



      share










      asked 4 mins ago









      RJMRJM

      1616




      1616






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          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: "196"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fcodereview.stackexchange.com%2fquestions%2f211847%2fchange-arithmetic-right-shift-to-logical-right-shift%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • 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.


          Use MathJax to format equations. MathJax reference.


          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%2fcodereview.stackexchange.com%2fquestions%2f211847%2fchange-arithmetic-right-shift-to-logical-right-shift%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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'