public static BitArray ShLo(BitArray B)
{
return new BitArray(System.BitConverter.GetBytes(Math.Floor((GetIntFromBitArray(B)/2) % (Math.Pow(2, 64)))));
}
private static ulong GetIntFromBitArray(BitArray bitArray)
{
var array = new int[2];
bitArray.CopyTo(array, 0);
return (uint)array[0] + ((ulong)(uint)array[1] << 32);
}
該方法需要很長時間。我可以優化它嗎?如何在此方法中優化數學運算?
將其拆分爲單獨的語句並獲得體面的分析器來查看_which_部分需要「很長時間」。直到你這樣做,你只是猜測。 –
你的方法實際上試圖實現什麼?它不利於我們不知道'GetIntFromBitArray'的作用... –
@JonSkeet更新代碼。現在GetIntFromBitArray方法在這裏。 –