C # 6, apparently, passed. The adapted test, MSVC 2015, issues:
::: Single precision :::
Right on test 0
Right on test 1
Right on test 2
Right on test 3
Right on test 4
Right on test 5
Right on test 6
Right on test 7
::: Double precision :::
Right on test 0
Right on test 1
Right on test 2
Right on test 3
Right on test 4
Right on test 5
Right on test 6
Right on test 7
Right on test 8
Right on test 9
Right on test 10
Right on test 11
Right on test 12
Right on test 13
Right on test 14
Right on test 15
Right on test 16
Right on test 17
Right on test 18
Right on test 19
Right on test 20
Right on test 21
Right on test 22
Right on test 23
::: Double precision (TestIEEE754ConvertionHard3.cpp) :::
Right on test 0
Right on test 1
Right on test 2
Right on test 3
Right on test 4
Right on test 5
Right on test 6
Right on test 7
Right on test 8
Adapted source:
class Program { // Тестирование числа одинарной точности void test32(float a, uint right, int testNumber) { var floatBytes = BitConverter.GetBytes(a); var uintValue = BitConverter.ToUInt32(floatBytes, 0); if (uintValue != right) Console.WriteLine($"Error on test {testNumber}: {uintValue:x8} != {right:x8}"); else Console.WriteLine($"Right on test {testNumber}"); } // Тестирование числа двойной точности void test64(double a, ulong right, int testNumber) { var ulongValue = (ulong)BitConverter.DoubleToInt64Bits(a); if (ulongValue != right) Console.WriteLine($"Error on test {testNumber}: {ulongValue:x16} != {right:x16}"); else Console.WriteLine($"Right on test {testNumber}"); } // Список чисел одинарной точности и правильных двоичных представлений этих чисел const int N32 = 8; float[] Test32 = new float[ N32 ] { 21267649200209254194690314461188718593.0f, 1.175494280757364291727882991035766513322e-38f, 1.175494280757364291727882991035766513323e-38f, 10749727.50000000000000000000000000000001f, 10749728.50000000000000000000000000000001f, -1.175494420887210724209590083408724842314e-38f, -1.175494420887210724209590083408724842315e-38f, -340282336497324057985868971510891282432.1f }; uint[] Right32 = new uint[ N32 ] { 0x7d800001, 0x007fffff, 0x00800000, 0x4b240720, 0x4b240721, 0x80800000, 0x80800001, 0xff7fffff }; // Список чисел двойной точности и правильных двоичных представлений этих чисел const int N64 = 24; double[] Test64 = new double[ N64 ] { -2.470328229206232720882843964341106861825e-324, -2.470328229206232720882843964341106861826e-324, 2.225073858507200641991763955462587799366e-308, 2.225073858507200641991763955462587799367e-308, 6755399441055826.499999999999999999999999, 6755399441055826.500000000000000000000001, 179769313486231560835325876058105298516207002341652166261661174625869553267292326574530099287946549246750631490335877017522087105926987962906277604735569213290190919152394180476217125334960946356387261286640198029037799514183602981511756283727771403830521483963923935633133642802139091669457927874464075218944.1, 11417981541647677146990387413251858846007164927.9, 11417981541647677146990387413251858846007164928.0, 11417981541647677146990387413251858846007164928.1, 11417981541647677780815687527366559594358767616.0, 179769313486231560835325876058105298516207002341652166261661174625869553267292326574530099287946549246750631490335877017522087105926987962906277604735569213290190919152394180476217125334960946356387261286640198029037799514183602981511756283727771403830521483963923935633133642802139091669457927874464075218943.9, 179769313486231560835325876058105298516207002341652166261661174625869553267292326574530099287946549246750631490335877017522087105926987962906277604735569213290190919152394180476217125334960946356387261286640198029037799514183602981511756283727771403830521483963923935633133642802139091669457927874464075218944.0, 179769313486231560835325876058105298516207002341652166261661174625869553267292326574530099287946549246750631490335877017522087105926987962906277604735569213290190919152394180476217125334960946356387261286640198029037799514183602981511756283727771403830521483963923935633133642802139091669457927874464075218944.1, 9214843084008499.0, 0.500000000000000166533453693773481063544750213623046875, 30078505129381147446200.0, 3.518437208883201171875e13, 8.10109172351e-10, 9007199254740991.4999999999999999999999999999999995, -2.-324, 6755399441055827.499999999999999999999999, 6755399441055827.5, 6755399441055827.500000000000000000000001 }; ulong[] Right64 = new ulong[ N64 ] { 0x8000000000000000, 0x8000000000000001, 0x000ffffffffffffe, 0x000fffffffffffff, 0x4338000000000052, 0x4338000000000053, 0x7fefffffffffffff, 0x497ffffffffffffe, 0x497ffffffffffffe, 0x497fffffffffffff, 0x497fffffffffffff, 0x7feffffffffffffe, 0x7feffffffffffffe, 0x7fefffffffffffff, 0x43405e6cec57761a, 0x3fe0000000000002, 0x44997a3c7271b021, 0x42c0000000000002, 0x3e0bd5cbaef0fd0c, 0x433fffffffffffff, 0x8000000000000001, 0x4338000000000053, 0x4338000000000054, 0x4338000000000054 }; // Более сложный тест из https://github.com/Zealint/fp_tests/blob/master/TestIEEE754ConvertionHard3.cpp const int N64Hard = 9; double[] Test64Hard = new double[ N64Hard ] { 2.-308, 2.-308, 2.-308, 2.-308, 2.-308, 2.-308, 2.-308, 2.-308, 2.-308 }; ulong[] Right64Hard = new ulong[ N64Hard ] { 0x0010000000000000, 0x0010000000000001, 0x0010000000000002, 0x0010000000000000, 0x0010000000000000, 0x0010000000000001, 0x0010000000000001, 0x0010000000000002, 0x0010000000000002 }; static void Main(string[] args) { new Program().Run(); } void Run() { // Проверка всех чисел одинарной точности в цикле Console.WriteLine("\n\n::: Single precision :::\n"); for (int i = 0; i < N32; i++) test32(Test32[i], Right32[i], i); // Проверка всех чисел двойной точности в цикле Console.WriteLine("\n::: Double precision :::\n"); for (int i = 0; i < N64; i++) test64(Test64[i], Right64[i], i); // Более сложная проверка (TestIEEE754ConvertionHard3.cpp) Console.WriteLine("\n::: Double precision (TestIEEE754ConvertionHard3.cpp) :::\n"); for (int i = 0; i < N64Hard; i++) test64(Test64Hard[i], Right64Hard[i], i); } }
Update: tests with long double cannot be transferred to C #, since there is no analogue to the long double data type (80 bits floating point) in .NET of the current version.
Update: added tests from https://github.com/Zealint/fp_tests/blob/master/TestIEEE754ConvertionHard3.cpp
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010OK. (Starting with -O2 (-Os?) -Wall and without -fno-strict-aliasing, a bunch of warnings likedereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]) What does it mean to fall for simple tests ? Directly - segmentation fault or zerodivide with core dump ??? - avp