public static void Main()
float compareValue = (float)Math.Pow(2, 31);
PrintFloatMessage("2^31 as a float: ", compareValue);
var compareBytes = BitConverter.GetBytes(compareValue);
PrintArrayMessage("2^31 as bytes: ", compareBytes);
bytes = BitConverter.GetBytes(compareValue + i);
for (int j = 0; j < compareBytes.Length; j++)
if (compareBytes[j] != bytes[j])
PrintFloatMessage("The next highest float is: ", compareValue + i);
PrintArrayMessage("The next highest float as bytes: ", bytes);
PrintFloat(compareValue);
Print(" + " + (i - 2) + " = ");
PrintFloat(compareValue + i - 2);
PrintFloat(compareValue);
Print(" + " + (i - 1) + " = ");
PrintFloat(compareValue + i - 1);
PrintFloat(compareValue);
Print(" + " + (i - 2) + ") == (");
PrintFloat(compareValue);
float f1 = compareValue + i - 2;
float f2 = compareValue + i - 1;
Print(" + " + (i - 1) + ") = " + (f1 == f2));
private static void PrintFloatMessage(string message, float value)
private static void PrintFloat(float value)
Print(value.ToString("G9"));
private static void PrintArrayMessage(string message, byte[] bytes)
private static void PrintArray(byte[] bytes)
Print("{ " + string.Join(", ", bytes) + " }");
private static void Print(string message)