Loading ...
Sorry, an error occurred while loading the content.

optimization

Expand Messages
  • Alessandro Zummo
    someone knows how this code can be optimized/beautified? -- Return the number of the first bit at 1 function getbit ( byte in b ) return byte is var byte
    Message 1 of 1 , May 1, 2001
    • 0 Attachment
      someone knows how this code can be optimized/beautified?


      -- Return the number of the first bit at 1

      function getbit ( byte in b ) return byte is

      var byte count = 0

      var bit bit_zero at b : 0

      forever loop

      if bit_zero then
      return count
      end if

      count = count + 1

      b = b >> 1

      end loop

      end function


      the byte in input has at least one bit at 1, so endless loop is avoided

      --

      - alex.
    Your message has been successfully submitted and would be delivered to recipients shortly.