public static void Main(string[] args)
Console.WriteLine($"{Math.Round(0.5)} = round(0.5)");
Console.WriteLine($"{ToBinaryString(0.5)} = binary 0.5");
Console.WriteLine($"{Math.Log(1, 2)} = log2(1)");
Console.WriteLine($"{ToBinaryString(Math.Log(1, 2))} = binary log2(1)");
Console.WriteLine($"{Math.Round(Math.Log(1, 2) + 0.5)} = round(log2(1) + 0.5)");
Console.WriteLine($"{ToBinaryString(Math.Log(1, 2) + 0.5)} = binary log2(1) + 0.5");
Console.WriteLine($"{Math.Round(0.0 + 0.5)} = round(0.0 + 0.5");
Console.WriteLine($"{ToBinaryString(0.0 + 0.5)} = binary 0.0 + 0.5");
Console.WriteLine($"{Math.Log(1, 2) + 0.5 == 0.5} = Math.Log(1, 2) + 0.5 == 0.5");
Console.WriteLine($"{Math.Log(1, 2) == 0.0} = Math.Log(1, 2) == 0.0");
static string ToBinaryString(double value)
const int bitCount = sizeof(double) * 8;
long intValue = System.BitConverter.ToInt64(BitConverter.GetBytes(value), 0);
return Convert.ToString(intValue, 2).PadLeft(bitCount, '0');