Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4771

IsPowerOf2 always return true

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: 2.21.0
    • Component/s: BSON
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      The function IsPowerOf2 from the PowerOf2.cs file in Bson project always return true :

      • 1 & 0 = 0
      • 0 & 1 = 0

      Simple Fix:

      ```cs

      # Replace

      var result = (n & (n - 1)) == 0;

      # By

      var result = n % 2 == 0;

      ```

            Assignee:
            Unassigned Unassigned
            Reporter:
            melvin.courjaud@e-i.com Melvin Courjaud
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: