Skip to content

Commit

Permalink
Temporary fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jkguttormsen committed May 24, 2024
1 parent 8149f33 commit 746a1a3
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions RevolveUavcan/Tools/BitArrayTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ private static BitArray FillBitArrayWithMSB(this BitArray bitArray, int finalSiz
/// </summary>
/// <param name="bitArray">The BitArray we want to calculate the corresponding ulong value for</param>
/// <returns>An integer representation of the BitArray</returns>
//public static ulong GetULongFromBitArray(this BitArray bitArray)
//{
// if (bitArray.Length > 64)
// {
// throw new ArgumentException("BitArray length cannot be greater than 64 bits.");
// }

// // Initialize bitArrayWithMsb with values from bitArray and fill it with MSB
// BitArray bitArrayWithMsb = FillBitArrayWithMSB(bitArray, 64);

// // Find and return corresponding integer value from bitArrayWithMsb
// int[] array = new int[2];
// bitArrayWithMsb.CopyTo(array, 0);
// return (uint)array[0] + ((ulong)(uint)array[1] << 32);
//}
public static ulong GetULongFromBitArray(this BitArray bitArray)
{
if (bitArray.Length > 64)
{
throw new ArgumentException("BitArray length cannot be greater than 64 bits.");
}

// Initialize bitArrayWithMsb with values from bitArray and fill it with MSB
BitArray bitArrayWithMsb = FillBitArrayWithMSB(bitArray, 64);

// Find and return corresponding integer value from bitArrayWithMsb
int[] array = new int[2];
bitArrayWithMsb.CopyTo(array, 0);
return (uint)array[0] + ((ulong)(uint)array[1] << 32);
}

/// <summary>
/// Calculate the long value of a BitArray
Expand Down

0 comments on commit 746a1a3

Please sign in to comment.