Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-33725

MathUtils.isPowerOf2 does not cover the case of value=0

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • API / Core
    • None

    Description

      org.apache.flink.util.MathUtils.isPowerOf2, 
       
      This static method does not cover the case of value=0.
      Should the document explain that value cannot be =0?
      Or could it be re implemented as the following code?
       
      public static boolean isPowerOf2(long value)

      {   return value > 0 && (value & (value - 1)) == 0; }

      Attachments

        Activity

          People

            Unassigned Unassigned
            callthingsoff Jes Cok
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: