[CSHARP-4771] IsPowerOf2 always return true Created: 24/Aug/23 Updated: 27/Oct/23 Resolved: 31/Aug/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | 2.21.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Melvin Courjaud | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | bug | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
SummaryThe function IsPowerOf2 from the PowerOf2.cs file in Bson project always return true :
Simple Fix:```cs # Replace var result = (n & (n - 1)) == 0; # By var result = n % 2 == 0; ``` |
| Comments |
| Comment by James Kovacs [ 31/Aug/23 ] |
|
Thank you for getting back to us. I will close as Works As Designed. |
| Comment by Melvin Courjaud [ 31/Aug/23 ] |
|
I apologize, I've mistested the function. It works correctly. |
| Comment by Melvin Courjaud [ 24/Aug/23 ] |
|
Sorry for the dead link in description, see https://github.com/mongodb/mongo-csharp-driver/blob/v2.21.0/src/MongoDB.Bson/PowerOf2.cs#L29
|
| Comment by PM Bot [ 24/Aug/23 ] |
|
Hi melvin.courjaud@e-i.com, thank you for reporting this issue! The team will look into it and get back to you soon. |